I have recently analysed my website with pagespeed addon on firebug. It suggested me to set expiration on CSS, JS and image files.
I am wondering how do i do this?
Webmasters Stack Exchange is a question and answer site for pro webmasters. It only takes a minute to sign up.Sign up to join this community
Update your Apache configuration to include the directives below as part of your core configuration:
You can put this in your htaccess:
<FilesMatch "(?i)^.*\.(ico|flv|jpg|jpeg|png|gif|js|css)$"> ExpiresActive On ExpiresDefault A2592000 </FilesMatch>
It will target files with those extensions (ico, flv, jpg and so on) and set the Expires header to be access time (A) plus 30 days (2592000 seconds). You can also add this at the server level if you have access to that.
It depend from the host and the way you server these things. Option 1) if you control the server make the apache to add expiration headers in the response Option 2) if you do not control the web server, or you server the images/js/css/etc you can set these headers from the script that server them
Have in mind that these hints are recommendable but not absolute truth. They are more to save you a bandwidth than to speed up your website . So if you have a low traffic to your site do not worry too much about this.
Setting up expires in Lightspeed Web Server
Login to Admin Console then >Server->General->Expires Settings->Expires By Type
Add the following:
604800 is the seconds of the expire, which should be suitable for your needs since its 168 hours which is 7 days. Additionally Light Speed Server does use a htaccess which you need to add the following line:
Alternatively if you do not have admin console access try the following the .htaccess file: