Speed Tips: Remove Last-Modified Header
« Speed Tips: Turn Off ETagsSpeed Up Google Analytics with urchin.js »
If you remove the Last-Modified and ETag header, you will totally eliminate If-Modified-Since and If-None-Match requests and their 304 Not Modified Responses, so a file will stay cached without checking for updates until the Expires header indicates new content is available!
Easy Apache Speed Tips Articles
Please don’t turn off ETags and Last-Modified headers for your .html files, leave one of them ON. (I use Last-Modified for .html).
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 remove all Last-Modified Headers from being sent.
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css)$"> Header unset Last-Modified </FilesMatch>
By removing both the ETag header and the Last-Modified headers from your static files (images, javascript, css) browsers and caches will not be able to validate the cached version of the file vs. the real version. By also including a Cache-Control header and Expires header, you can specify that certain files be cached for a certain period of time, and you magically (this is a really unique trick I promise) eliminate any validation requests!!
« Speed Tips: Turn Off ETags
Speed Up Google Analytics with urchin.js »
Tags: Cache, etag, Headers, htaccess, http, Last-Modified
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
This is what I currently have in my .htaccess file at the root. Do you see any problems with what I have here?
First off, once your rules are correct be sure to move the rules out of .htaccess and into the httpd.conf file for the Directory section of your DocumentRoot. Why? .htaccess is inherently slow as it must be read for each and every request that starts in or goes deeper than the directory in which it resides (and for which AllowOverride is enabled).
See the Apache documentation for .htaccess files for more information
This is what I currently have in my .htaccess file at the root. Do you see any problems with what I have here? Would you organize it differently? I don’t know much about .htaccess files, but would love to see if this is ok for my server. Here it is below…
FileETag None Header unset ETag Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate" Header set Pragma "no-cache" Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT" Header unset ETag FileETag None SetOutputFilter DEFLATE Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT" Header unset Last-Modified
Thanks for your help!
BTW…auto-playing music is a good way to lose traffic. Is this a MySpace page?
Yes, this will speed individual requests, but for those sites with actual traffic they may crawl to a halt due to re-requested content from frequent visitors (think RSS feeds) and spiderbots (Google, etc.). It’s a trade-off that massive scalable systems must consider: slow each request a little to be able to serve all requests reasonably fast.
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 Magazine ::.
↑ 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
I love this tip. I’ve done a lot of optimization research and actually nobody ever suggested to remove the Last-Modified header and it’s interesting to know that the browser will not pass in those “If-” requests which is once again less bytes that have to travel across the web.
My only question is why are you suggesting NOT to remove the Last-Modified header for .html files?