WordPress Developer Dossiers May 10, 2017

How Pressidium implements browser caching

Yorgos Fountis

2 min read
Share
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.

Intelligent WordPress Caching.

Discover Enterprise Performance
Share

Did you like this article?

Subscribe to our blog and get awesome WordPress content straight to your inbox.

SUBSCRIBE

OUR READERS ALSO VIEWED:

Image for WordPress Password Security and Hashing
09 November 2017

WordPress Password Security and Hashing

In this article we take a look at password security, WordPress password hashing, and how you can go about implementing your own.
Yorgos Fountis
Yorgos Fountis
5 min read
Image for WordPress Object Caching: Redis, Memcached and native APIs

WordPress Object Caching: Redis, Memcached and native APIs

Object-caching can either be a jet-engine or sand in your gas tank. We take a look at Redis, Memcached, and the native WordPress APIs.
Yorgos Fountis
Yorgos Fountis
8 min read
Image for WordPress Developers: Start Here!

WordPress Developers: Start Here!

If you are a WordPress developer with little free time, this 2500 word starter guide will get you going from brainstorming to deployment!
Yorgos Fountis
Yorgos Fountis
15 min read