« Faster Form Submission and Processing with fsockopenHack WP-Cache for Maximum Speed »
Speed Tips: Add Cache-Control Headers
Using Cache-Control headers you can specify which types of proxies can cache certain content, and how long files should be cached. You can also add the must-revalidate header to force checking the ETag and or Last-Modified for the file to make sure the cache is using the current version.
Easy Apache Speed Tips Articles
Keep in mind, if you use a far future Expires header you have to change the component’s filename whenever the file changes. So please add must-revalidate to your Cache-Control header for your .html files.
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 Cache-Control Headers to certain files.
# 480 weeksHeader set Cache-Control "max-age=290304000, public" # 2 DAYSHeader set Cache-Control "max-age=172800, public, must-revalidate" # 2 HOURSHeader set Cache-Control "max-age=7200, must-revalidate"
If you are using far Future Expires Headers and Cache-Control (recommended), you can do this for these files.
Header set Cache-Control "public" Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"


You can use the HTTP Header Viewer Tool to check it.
Header unset Pragma FileETag None Header unset ETag # 1 YEARHeader set Cache-Control "public" Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT" Header unset Last-Modified # 2 HOURSHeader set Cache-Control "max-age=7200, must-revalidate" # CACHED FOREVER # MOD_REWRITE TO RENAME EVERY CHANGEHeader set Cache-Control "public" Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT" Header unset Last-Modified
« Faster Form Submission and Processing with fsockopen
Hack WP-Cache for Maximum Speed »
Tags: Cache, Headers, htaccess, optimization
The love of liberty is the love of others; the love of power is the love of ourselves.
-- William Hazlitt
Please consider donating to support active development of the free software and articles here.![]()
The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect. Tim Berners-Lee
Very good explanation, but I don’t know why it don’t works for me :( Maybe it’s my hosting …
Hi,
I ‘ve added cache control in my .htaccess like this.
#Header set Cache-Control "max-age=290304000, public"
But by adding it its giving me 500 internal server error as soon as i remove it, it starts working.
What should be the problem behind this?
Thanks.
Thanks that’s highly useful. Cache headers can be highly useful.
I had AOL Hosting FTP – Now new to DSN Hosting – got a good HOST – but when I upload a “OVERWRITE” file replacement – it taks at least 4- 6 hours for the replacement file to take hold and show. They say this is cause AOL use ‘Proxy Caching Servers’ which hold the last known version of a web page. I don’t understand the code I need to overcome this caching – I have tried cleaning all caches browser and AOL – but still don’t work.
I’m sure the answer is in the above box – Easy Apache Speed Tips Articles – but don’t understand – I know HTML code pretty well and never use an Editor. I’m lost here. Any help would really be appreciated..
Claude
Hello, very nice site, keep up good job!
Admin good, very good.
It's very simple - you read the protocol and write the code. -Bill Joy
HTML | DCMI | GRDDL | XOXO | XDMP | XFN | DOM | XML | XHTML 1.1 Strict | CSS 2.1 | W3C | TLDP | WAI | DISA | ICSI | GIAC | SANS RR | GHOST | DEFCON | NIST | DHS CYBER | NIST | Phrack
↑ TOPExcept 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. HTTPD based on NCSA HTTPd
Thanks for these tipps. They helped me a lot! I hope my website is now faster as ever ;-)