View Full Version : How to set the expiration date for static resources in a webpage?

01-25-2012, 10:56 AM
hello friends,

i checked the page loading speed of my website from google page speed online and score out the 48 out of 100. This is a matter of worry for me. The checker tool show me the following errors: -

Leverage browser caching: -

When i go through this then this show me "Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network."

As the instruction's are given there and form some other article i set expiration date with following code
<meta http-equiv="expires" content="mon 01, jan 2013 00 00 00 GMT" />
but when i check its validation then it show me error of not valid value for http-equiv attribute and also the same error persist again. how i resolve it please help??

01-25-2012, 11:57 AM
how i resolve it please help??This needs to be done on your server. I'm not sure what the best way to do it is.

Presumably, you can do it on a per-file basis with PHP:

header("Expires: Sat, 31 Jan 2099 00:00:00 GMT");

That's not very efficient though. There's probably a way to set it for all your files by default, but I don't know what it is.