Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Google's PageSpeed plugin suggests that a website should include Last-Modified and ETag headers:

Specify a cache validator "Resources that do not specify a cache validator cannot be refreshed efficiently. Specify a Last-Modified or ETag header to enable cache validation"

However, Apache suggests that by not including them at all, we speed up websites by eliminating If-Modified-Since and If-None-Match requests:

http://www.askapache.com/htaccess/apache-speed-last-modified.html

these are in direct opposition - which should be implemented? I'm leaning towards Apache's suggestion, as when I want a file cached, I don't want it refreshed.

share|improve this question

1 Answer 1

The point is to get the browser to cache resources your site uses wherever possible, as this reduces either HTTP requests or data transferred, both of which help speed. You do this either by setting Expires headers, which tell the browser to cache the resource until the specified time; or by using Last Modified / Etags, which give the browser a way to work out if the resource it has previously cached needs to be updated.

The tips page you linked to (which is not an official Apache resource) states:

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!

the important point there being "...until the Expires header indicates...", so the advice given is valid if you are supplying an Expires header instead.

Expires headers give more of a speed improvement if you can use them, as when using Last Modified headers and Etags, even if all the resources are cached the browser still has to send the requests to the server, which takes time.

Google's speed recommendations have a pretty good write up.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.