I am currently working on a new project where the entire page should be implemented in HTML5/JS working against an API/JSON. Since the entire application should only consist of one HTML file (index.html) and a JS MVC application (maybe backboneJs) I am thinking about SEO and user friendly urls.
There I came across
window.document.pushstate('','title','/url');
With the help of that html5 feature I can define URLs without really leaving or reloading the page. BUT... I want to deploy the application into a CDN like Amazon CloudFount for performance reason and low expenses. I would not need any server infrastructure (besides the one I need for the API of course)
So can I configure a CDN (really any CDN like AWS, Azure, Akamai) to provide the same HTML file no matter what URL is called
http://www.example.com => delivers index.html
http://www.example.com/any_subpage => delivers index.html
and so on ...
an working example you can find at http://html5.gingerhost.com. But the creator of that page may use an .htaccess file or something familiar to map everything to the same file. I want to provide the same functionality in a CDN.
A content delivery network (CDN) is a group of geographically distributed servers that speed up the delivery of web content by bringing it closer to where users are.
In a CDN, the edge servers are where the data is cached. CDN caching works roughly as per the following steps: An end user requests for static assets on your web page for the first time. The assets are retrieved from the origin server and once delivered are stored in the PoP edge caching server close to the end user.
What is CDN caching? A CDN, or content delivery network, caches content (such as images, videos, or webpages) in proxy servers that are located closer to end users than origin servers. (A proxy server is a server that receives requests from clients and passes them along to other servers.)
Any CDN should have the capability of defining an origin server. This server gets contacted by the CDN to serve the file if the edge location doesn't have it.
The good news is that the origin server can be anything that serves web pages, such as Apache, Nginx, etc. This means that you can apply any kind of rewriting rules you wish.
If you don't wish to set up the origin server yourself, you could look at hosting your (static) site on S3. Recently they have introduced web redirects which may help you to to serve the same file under a different "alias". Failing that, you could look at redefining the standard error document, but I'm not sure whether an error status code will still be sent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With