Add Far Future Expires Headers
This is the third part of the article Speeding Up your Web Site. The method is really easy to configure and will drastically increase the speed of your web page. I found this optimizing tip at askapache.com:
Just put the following lines in your
Store the
By adding these headers I've reduced the load time of this website for the second page view from 3.55 sec to 1.74 seconds. Actually the page rendered completely in 1.16 seconds, but the loading of the video playlists which is asynchronous added some to the total time. At the left you can see a speed graph created by Safari.
For Nucleus users I also have an additional tip to make maintaining your website even easier. Check it out below.
As noted above you should always change the component’s file name whenever you change a file with a far future expires header. This can be a real drag if you change your files a lot. A workaround is instead of changing the filename, just change the name of your skin folder at the "configuration" page in the admin area.
For example to: http://your-nucleus-website.com/skins1.0.1/
Then with a bit of mod_rewrite magic we can point to the original skin folder at:
For example: http://your-nucleus-website.com/skins/
...add this line to the
Now you just have to change 1 setting at the configuration page instead of changing al the filenames of the files you edited.
A first-time visitor to your page will make several HTTP requests to download all your sites files, but using the Expires header you make those files cacheable. This avoids unnecessary HTTP requests on subsequent page views.
Just put the following lines in your
.htaccess file:<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"
</FilesMatch>
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"
</FilesMatch>
Store the
.htaccess file in the directory from where you want to start adding the far future header, so if you store this in the root all the files on your server with the extensions above will get a far future expires header.Note: if you use a far future Expires header you have to change the component’s file name whenever the file changes.
By adding these headers I've reduced the load time of this website for the second page view from 3.55 sec to 1.74 seconds. Actually the page rendered completely in 1.16 seconds, but the loading of the video playlists which is asynchronous added some to the total time. At the left you can see a speed graph created by Safari.
For Nucleus users I also have an additional tip to make maintaining your website even easier. Check it out below.
As noted above you should always change the component’s file name whenever you change a file with a far future expires header. This can be a real drag if you change your files a lot. A workaround is instead of changing the filename, just change the name of your skin folder at the "configuration" page in the admin area.
For example to: http://your-nucleus-website.com/skins1.0.1/
Then with a bit of mod_rewrite magic we can point to the original skin folder at:
For example: http://your-nucleus-website.com/skins/
...add this line to the
.htaccess file in your root replacing the "default" with your current skin nameRewriteEngine On
RewriteBase /
RewriteRule ^skins.*/default/(.*)$ skins/default/$1
RewriteBase /
RewriteRule ^skins.*/default/(.*)$ skins/default/$1
Note: if your preexisting .htaccess file already uses URL rewriting you do not need to add the first two lines. You can simply add the last line to the bottom of the .htaccess file
Now you just have to change 1 setting at the configuration page instead of changing al the filenames of the files you edited.
- 2008Nov 23
- PUBLISHED IN Optimization


