Tutorials UPDATED: 26 February 2023

How Pressidium implements browser caching

Yorgos Fountis

2 min read
Image for How Pressidium implements browser caching

Previously, we delved into the browser cache and explained the various cache-related headers you can use in order to optimise your website and make it snappier. The HTTP protocol has gone through several iterations; HTTP/1.0 and 1.1 with each of those implementing their own set of browser caching headers. For example, HTTP/1.0 used the Expires keyword along with Pragma: no-cache directive to specify an exact “best by” date and to further instruct the browser not to cache anything if no caching was needed.

The different implementations, browsers, and server topology can quickly make browser caching a daunting task; but this is where we enter the picture.

Pressidium’s browser caching policy

We treat dynamic content differently from static content. Dynamic content is forced to be revalidated every time the browser requests it. This is only logical; if you cached dynamic content, then it wouldn’t be considered dynamic! This is implemented using the must-revalidate, max-age=0 directives in Cache-Control. This forces the browser to ask the server if the copy it has in its cache is the most recent one. However, max-age=0 forces the browser not to keep anything in its cache. These two directives effectively make sure that dynamic content is always fetched from the server, no matter what.

Cached static content on the other hand (such as images, CSS files, javascript, etc) is configured to be good for 30 days.

Additionally, we use the Expires keyword, strictly for backwards compatibility reasons; calculating its absolute value according to Cache-Control‘s max-age value. The Expires keyword takes an absolute value in the form of an expiration date, whereas the Cache-Control: max-age=n keyword specifies a relative value (n). This value specifies for how long the content can be considered fresh once it is cached.

HTTP/1.1 also introduced another header called Etag that works as a sort of “fingerprint” for content. Every content gets associated with an Etag value (which is generated by the web-server using a variety of ways). Whenever the content changes, the Etag value changes as well, thus, signalling the need for the browser to get a fresh copy. Etag is used in Pressidium only for static files, and it is generated using the file’s modification time and size. This simply means that the web-server generates a new Etag value every time the content is modified.

The implementation of a browser caching policy is something that you don’t need to fuss about if you’re a Pressidium client. Should you ever have questions related to browsing caching or experience any problems do not hesitate to contact us. We provide end-to-end support and we mean it.

Start Your 14 Day Free Trial

Try our award winning WordPress Hosting!

START YOUR FREE TRIAL VIEW OUR PRICE PLANS

OUR READERS ALSO VIEWED:

Build a WordPress OOP Plugin: An Object-Oriented Programming tutorial

Follows us on a step-by-step tutorial on how to create a custom WordPress plugin using Object Oriented Programming (OOP).
Tassos Antoniou
Tassos Antoniou
27 min read

Render Blocking: What it is, Why it Matters, and How to Fix it on Your Website

Render blocking can significantly slow down your website loading time. Find out what it is and how to fix it in this article!
Tassos Antoniou
Tassos Antoniou
8 min read

SQL Injections And WordPress

Take a look at some real-world examples of SQL injection attacks & find out what you can do to protect your website from them in this article!
Tassos Antoniou
Tassos Antoniou
9 min read

WordPress Render Blocking

Render blocking can slow down the time it takes for your website to load. Let's look at some WordPress specific render blocking issues.
Tassos Antoniou
Tassos Antoniou
5 min read
SUBSCRIBE