This post has been archived
The content of this post has not been updated since 2016, and may be out of date. Extra care should be taken with any code provided.
Expires headers let the browser know whether to serve a cached version of the page. This can simultaneously help to reduce server load and increase page load time by telling the browser that it doesn’t have to check for new versions of files for an extended period.
The code below will allow images to be cached for a year and text-based content to be cached for one month. For most fairly static websites (like this one) that doesn’t change very often aside for a new post now and then this should be more then enough.
If you are running a dynamic website be careful with any sensitive information which may be stored, for example JSON responses, user account pages and the like should be set-up to not cache.
The above can be copied into your .htaccess file without any major issues but, of course best checked before deploying to a live environment.
November 2024
In today’s digital world, protecting your privacy online has become essential. With personal data constantly being shared, stored, and potentially accessed by unauthorised parties, safeguarding...
→ Continue reading"Simple steps to protect your privacy online"
November 2024
Making the most of Bluesky after coming from whatever Twitter (𝕏) has become involves exploring the platform's unique features, adapting to its smaller, community-driven culture,...
November 2024
With the increasing dependency on web applications in daily operations, securing these applications is paramount to safeguarding data and protecting against breaches. This blog post...