One of the most important strategies to improve site performance is to cache content.
Caching content means to store content (such as images, scripts or HTML documents) in a location closer to your users (or in the browser itself) which means that that websites load much faster and there can be significant cost savings as requests for the same content do not have to be generated by your hosting servers every time.
When improving site performance (and overall business revenue through improved speed) its important to be able to understand why it's necessary to have a tradeoff between site speed and how quickly users see content updates.
Strategies for Site Updates when Content Caching
When caching content it's important to consider what happens when someone makes a change to your website.
A common example of making a change is someone updating an image or updating the text or status of a product.
When the update is made this will be implemented straight away in the application in your hosting environment, however your users will still be getting the cached version until the content expires (Expiry time is set via the origin application or manual configuration).
A key tradeoff in having a fast website is understanding how long to cache for. The longer you can cache the better - the faster your website will be for all users.
In order to balance performance with the ability to view updates to websites we recommend the following strategy:
1) Have different methods to check your website for internal staff and the public
Generally internal staff need to see updates straight away. We recommend the following method for internal staff to see their content updates.
Add a query string to the url of your page. When you have a page like www.site.com/product.html and the content of either the HTML document itself or images on this page are being cached you would add the following when loading the page in your browser:
Adding the text "?123" to the end of the page name will cause the page to be served straight from your origin application and bypass any caches.
(An alternative if there is already a query string question mark: "?code=something" on your url is to change this to "?code=something&123" which will also force a fresh page)
Each time you want to view the page bypassing any caching you should change the number in the url.
Eg viewing the same page again:
The normal Public:
For members of the public we recommend to always let the cache time expire. This could be 30mins - 1hr or more however the performance benefits from having a small delay in the public seeing an update are huge.
2) Understand when things are ok to be slightly out of date.
A common issue encountered when caching is to have all updates to products / categories instantly visible.
There are generally good intentions behind this requirement so that users do not see older content.
From a business perspective its worth considering the performance benefits (and sales revenue, site availability and cost of additional hosting hardware) of allowing pages to remain in cache until expiry time.
If a product has gone out of stock, If this was still visible on the Category page for 30mins is there a measureable business impact?
Keeping products on Category pages would allow you to have a long cache time on Category pages which will be a huge performance win.
To take the example one step further if the Product page did not prompt that it's out of stock until the user hit the "add to cart" button would this have a measureable business impact?
Allowing Product pages to be cached for a long time in addition to Category pages can yield huge performance benefits.
Conclusion and How to see the benefit for yourself:
If there are concerns around updates to content and the business impact of users seeing slightly out of date content, Its a simple experiment to test different cache times.
Industry (and internal section.io) data demonstrates that there are improvements to checkout volumes, sales revenue and dramatic site speed improvements through caching content as long as possible.