Automatically Add Content Expiry dates
• Faster page loading speeds
• Reduction in network traffic
• Reduction of load on webservers
• Better google search results (due to google webpage speed ranking)
Many web sites and applications don’t have the server correctly configured to add content expiry images.
This means that the Browsers can’t cache the images and other media correctly.
Browsers are pretty clever and many have an aggressive caching mechanism however IF an object such as an image is sent and there is no content expiry added then the browser will need to check if it’s still ok to use the copy it has already cached.
So when a browser makes a second request to the server and the object has not changed, it will return a message 304 Not Modified. This means all is well please use the object you already have stored locally as I’m not going to send it again.
The problem is that whilst it’s a small transaction it’s still treated by the browser/server as a normal transaction that is needs to be processed. It’s a wasted transaction as it uses network and browsers resources. This can slow down the site and application especially over the internet or mobile networks where latency is higher.
Some sites have 100’s of objects therefore there can be loads of wasted/preventable transactions.
Google speed test also checks for objects without sensible content expiry times.
How does it work?
The rule will apply a long content expiry of 31536000s (that is 1 Year to us normal people)
First it will check that it’s not a normal text page by checking the Content_Type does not contain text/html
It will then replace the Cache-Control response header with the new value
Feel free to tweak the rule – Have fun!