Cache Control & Filename Fingerprinting
Whether browsing the internet on a computer, phone or tablet; caching is something we have all heard of and most of us have at some stage come across the advice to clear our browser's cookies and cache. But for web developers a deeper understanding of how caching works and how to control it is often required.
So what is browser caching?
Web Page Speed & Optimal Caching
If you’ve ever run your website through one of the many page speed test tools that are available online you might have got a report back that recommends setting up optimal file caching for your website. By default most web browsers will cache automatically to a degree however it is usually a much shorter time than what is generally recommend and often the cached files are discarded when the session ends by closing the browser.
Setting up Cache Control on your server
So now we know how caching works and how it can speed up a website but how do we let the browser know how long you want it to cache your website’s resources? Well this can vary depending on your web server setup and the hosting control panel you are using. Some hosting control panels will give you the ability to set this and sometimes you will have to use a htaccess file to create caching rules with expiry times for specific file types. You will need to look into which cache control method is best suited to your particular setup.
Web Design, updating website and refreshing the page
Once cache policies are setup on your website server; web page resources will be cached by the browser for longer, web pages will load faster and the page speed tools, search engines and visitors will all be a little bit happier. Yay!
But what happens when you make changes your website? For example you make some style changes to a css file but the website is still using the old styles because it’s loading the old css file from the browser cache and not the file you‘ve just uploaded. Well as the web designer you know the problem so you can just clear the cache in your browser settings or do a full page reload but what about visitors to your website? They might not necessarily know to do this and could end up seeing a broken page with a mix of new and old file resources. Well the best way to ensure the newest version of a file is used is to change the filename. The browser will see that this new file does not already exist in the cache and will download the new version from the server. This is called cache busting and the method of naming files uniquely to bust the cache is called fingerprinting.
Automatic Filename Fingerprinting in XT CMS