What’s a server cache and why is it used?
- Web pages are made from multiple components, which are stored in various locations on the Mosaic database and server filestore. Gathering these parts to combine them into a page uses the server’s resources and takes time to complete.
- The server cache is a repository for storing ‘ready-made’ versions of pages – it also means the server doesn’t have to use resources to recreate frequently-requested pages
- Serving pages from the cache also results in much faster page loading and improves website visitors’ browsing experience, and frees up server resources to run other important background tasks
How do pages get in the server cache?
- If a Mosaic page is not already stored in the server cache, when that page is requested by any browser, a version of it is assembled from the resources in the database and filestore and stored in the assembled state in the server cache
- When a page which is stored in the server cache is subsequently requested again, the requestor is given a copy of the ‘ready-made’ page from the cache
- The maximum amount of time a page will stay in the cache is 7 days
How do pages get removed from the server cache?
- When an editor updates a page (by clicking ‘Publish Now’), the old version of the page is queued to be removed from the server cache – it usually takes between half a minute and several minutes to ‘purge’ the page from the cache. The amount of time purging takes depends on the amount of editing happening on the platform at the time
- When a page is no longer in the server cache and it is requested again, a new version of it is assembled from the resources in the database and filestore, including all the updates made since the last time the page was cached. This new version is served and stored as an updated copy in the cache
Viewing pages as a logged-in user
- Browsing a site while logged-in will be slower than viewing it as a non-logged-in user: when you are logged in to a Mosaic website (either as a content editor of the site or to view Oxford-only content) you bypass the server cache and only see content delivered freshly assembled from the server.
Publishing a page and server cache purging
Whenever the ‘Publish Now’ button is used to publish the edits made on a Mosaic page, the following process should occur:
- The previous published version of the page is queued to be purged from the server cache*
- The purge queue is processed and the previous published version is removed – this usually takes within the region of half a minute but can take up to several minutes, depending on the amount of editing happening on the platform
- The next time the page is requested (by anyone), the newly published version of the page is stored in the server cache
- As long as the page is not published again**, the new version of the page will stay in the server cache and be served to anyone who requests it for the next 7 days
- At the end of the 7 days the page will expire from the server cache and if requested again, step 3 will happen again
*requesting a page directly from the server means asking the server to find, combine and deliver all of the components which comprise the page. This can be relatively-resource intensive and would add a large amount load to the server for pages which are requested frequently. Whenever a page is requested directly from the server a version of the ‘ready-made’ page is stored in the server cache so the page can be quickly served to anyone else who subsequently requests it. This speeds up the experience of browsing pages and reduces load on the server.
**if the page is published again, the process will begin from step 1 again.
Potential problem: you have saved your page updates by clicking ‘Publish Now’ but you are concerned that the updates aren’t visible to your end-users.
Please note: the update process is not instant; it can take between half a minute and up to several minutes, depending on the amount of editing happening on the platform, for updates to be visible to non-logged-in users. If you have waited more than 15 minutes and the updates are not visible, try the following steps.
The update process is not instant
The server cache purging process means it can take between half a minute and up to several minutes, depending on the amount of editing happening on the platform, for updates to be visible to non-logged in users.
If you have waited more than 15 minutes and the updates are not visible, try the troubleshooting steps.
Eliminate the possibility that you are seeing browser-cached content
As well as the server cache storing a version of the page, your browser will most likely also store a copy of the pages you visit (read this article for more information about browser caching). To remove the possibility that you are seeing a browser cached version of the page:
- Either: clear your browser’s cache; or, open an incognito/private browsing session (which contains no cached content)
- Visit the page you have just updated
- Check whether the updated content is visible:
- If the content is updated, the server cache is delivering the updated content to your end-users
- If the content is not updated, try refreshing the live page (see the section below)
Refresh the live page
In the editing menu of each page, there is a ‘Refresh live page’ button (see the screenshot below). Using this button will prompt the server cache to remove the current published version of the page so that the updated version can be assembled from the server resources and stored in the server cache.
To use the ‘Refresh live page’ option:
- Press the ‘Refresh live page’ button on the page you want to update
- Wait for the refresh process to complete – when complete, the button will be green and the text will read ‘Live page updated’, e.g.:
To check the updates are visible to end-users:
- After the refresh process is complete, open an incognito/private browsing session (which does not contain any cached content)
- As a non-logged-in user, visit the page you were trying to update
- Check whether the updates are visible
- If the content is updated, the server cache is delivering the updated content to visitors
- If the content is not updated:
- Close the incognito/private browsing session
- Wait for up to 15 minutes
- Open a new incognito/private browsing session
- Repeat steps 2 and 3
- If the updates are not visible after this, please let the Oxford Mosaic team know by emailing email@example.com and providing details of the page you were attempting to update (please include the page’s URL)
A note about updating pages which are referenced in listings on other pages
If the page you are updating is referenced in a listing (e.g. a Grid listing or List listing widget) on another page, the page containing the listing should also be updated as part of the update process.
A listing item referencing the ‘Plan a website’ page (https://oxfordmosaic.web.ox.ac.uk/plan) appears in the Grid listing on the ‘How-to…’ page (https://oxfordmosaic.web.ox.ac.uk/howto). If an update to the ‘Plan a website’ page is published, the current published versions of the ‘Plan a website’ and ‘How-to…’ pages should both be updated.
If updates are made to the ‘Plan a website’ page’s listing information (which is visible on the ‘How-to…’ page), and those updates are not visible, the troubleshooting advice also applies to the ‘How to…’ page.