Have you made changes to a webpage but the changes didn’t reflect on your site straight away?
Welcome to the world of caching.
What is it and why do we do it?
It takes up to four hours for webpages on the Squiz site to cache. The reason for this is because if we were all updating our content at the same time it would make our website incredibly slow, making it a poor user experience for our students, prospective students, and staff. To avoid this, the Squiz server is set to check for changes to the website once every four hours. It saves a copy of all the pages it finds, and ‘serves’ them up to viewers.
If you want to view your new content immediately, it’s a simple matter of appending /_nocache to the url. This will allow the browser to load your new page directly from the server before it is cached.
It’s a handy trick to know if you are in a hurry to see how your new content looks, or if you want to show it to a colleague on their computer.
A simple explanation
One of the best explanations of “caching for dummies” I’ve found is at the Caching Explained website
To give people an understanding of how caching works, a speaker at a WordPress conference asked the audience “What’s 3,485,250 divided by 23,235 ?”
Everyone fell silent.
Some people pulled out calculators to do the maths, and finally someone yelled out the answer after a few seconds.
Then the speaker asked the same question again. This time everyone was able to immediately call out the answer.
This is a great demo of the concept of caching.
The initial time-consuming process was done once, then after that, when the same question was asked, the answer was readily available, and delivered much faster.
When applied to the context of your website, this translates to the ability to deliver a webpage with a super-fast response time without having to do all the time-consuming processing every time the page loads.
The first visitor to a particular page on your site is “asking the question” and your server provides the answer. The next time a visitor goes to the same page, ie. “asks the same question”, your server can provide the answer, i.e the web page, much faster.
When you make updates to your website, the code changes. When this happens, you have effectively changed the question and therefore changed the answer.
The problem then arises that it is not so easy to convince a room full of people that the answer they knew before has now changed.
To add to our problems some of the people in the room have told other people the old answer. People that are not in the room that we have no control over.
What I mean by "other people" is that your own computer’s browser will also save cache information and will continue to show your site from the previous version. In addition, the Squiz server also saves the information and only refreshes it every four hours, so it also serves up the old answer for a little while.
Refreshing the browser a few times can often be the solution but sometimes caching is stubborn and it may just be a case of waiting.
Can’t we just turn it off?
Unfortunately, the downside of caching is something we must tolerate; simply because the mild inconvenience of changes not being immediately visible is far outweighed by the increased speed and efficiency of our website and server.
More useful information about caching