Caching is a topic that is very important to website performance and your web application.
It’s important to understand that unless you implement a cache management strategy in your origin servers, you may find issues in your web application when you release changes. The applies with or without section.io as there is a general best practice that needs to be implemented.
The 2 most common cache management strategies are:
- Versioning - You add a unique id to your website resources that you update each time you make a change. eg style.css becomes style-1234.css and then styles-1235.css. You choice of versioning id is your own (Good options can be: release/build number, checksum or timestamp).
Using this method means that the instant you update your website all of your users will have access to the new version.
- Setting cache control headers - Its recommended to set an HTTP header on request responses of Cache-Control: max-age=… to set the number of seconds you wish to for your resources to be cached (by browsers, proxies, CDN’s or section.io).
Using this method, once you release a new version you will have to wait the number of seconds you have specific before your users will have access to the new version.
If you are using section.io we recommend setting a 5min max-age. This is because our infrastructure is able to give you the best of both worlds, We will check for new content every 5mins but we will implement a version hash and modify the max-age to 1 year. This means that when you release code, our system will detect the change within 5mins and generating a new hash for the resources to update users. If a new version has not been released with our 5min check, users will continue to use their cached copy.
Even without section.io, if no header is set and no file versioning is used then content will be cached in your users browers indefinitely. Until all users hard clear their local brower cache they will not see the new file version.
If you need assistance or cannot set either of the above options, contact section.io support. We may be able to implement option 2 for you without a code change on your origin servers.
We should note that we do have a “Clear CDN cache” option inside the section.io portal to remove all of your content from our cache. This is more of a last resort option rather than something you use on a day to day basis when releasing code (You cannot clear the cache of your users web browsers so this does not provide an effective cache management strategy.