Home  »  Htaccess  »  Speed Tips: Add Future Expires Headers

by 21 comments

With Expires HeaderA 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. Expires headers should be used on all components including scripts, stylesheets, and Flash components.

Add Future Expires Headers

Keep in mind, if you use a far future Expires header you have to change the component's filename whenever the file changes.

This goes in your root .htaccess file but if you have access to httpd.conf that is better.

This code uses the FilesMatch directive and the Header directive to add Future Expires Headers to certain files.

Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"

Without Expires Headers

No Expires Headers

With Expires Headers

With Expires Header


September 10th, 2007

Comments Welcome

Related Articles

My Online Tools
Popular Articles

Hacking and Hackers

The use of "hacker" to mean "security breaker" is a confusion on the part of the mass media. We hackers refuse to recognize that meaning, and continue using the word to mean someone who loves to program, someone who enjoys playful cleverness, or the combination of the two. See my article, On Hacking.
-- Richard M. Stallman


It's very simple - you read the protocol and write the code. -Bill Joy

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution 3.0 License, just credit with a link.
This site is not supported or endorsed by The Apache Software Foundation (ASF). All software and documentation produced by The ASF is licensed. "Apache" is a trademark of The ASF. NCSA HTTPd.
UNIX ® is a registered Trademark of The Open Group. POSIX ® is a registered Trademark of The IEEE.

+Askapache | askapache

Site Map | Contact Webmaster | License and Disclaimer | Terms of Service

↑ TOPMain