my php-generated thumbnail files and combined javascript and css files (all having their expiration dates anc cache=public set etc) return the full content sometimes, other times they load from proxy cache!
This is the comment that redbot.org gives, sometimes:
An If-Modified-Since conditional request returned the full content unchanged.
*HTTP allows clients to make conditional requests to see if a copy that they hold is still valid. Since this response has a Last-Modified header, clients should be able to use an If-Modified-Since request header for validation. RED has done this and found that the resource sends a full response even though it hadn't changed, indicating that it doesn't support Last-Modified validation.**
the PHP thumbnail generator header
header ("Content-type: image/jpeg");
header ("Last-Modified: " . gmdate("D, d M Y H:i:s", time() - 404800000)." GMT");
header ("Expires: " . gmdate("D, d M Y H:i:s", time() + 2419200) . " GMT");
header ("Cache-Control: public, max-age=2419200");
htaccess
<IfModule mod_headers.c>
ExpiresActive On
ExpiresDefault M172800
##### DEFAULT EXPIRES
<FilesMatch "\\.(ico|jpg|png|gif|svg|swf|css|js|fon|xml|pdf|flv)$">
ExpiresDefault M1209600
Header set Cache-Control "max-age=1209600, public"
</FilesMatch>
##### DYNAMIC PAGES
<FilesMatch "\\.(php|cgi|pl)$">
ExpiresDefault M7200
Header set Cache-Control "public, max-age=7200"
</FilesMatch>
Header unset Pragma
Header unset ETag
Header unset Last-Modified
FileETag None
</IfModule>
Update: New Info:
google SpeedTest gives 91/100 score on the top it says: and list all the files except the php generated files that have a explicit expire header set ((which still return full content!??) it says:
The following resources are missing 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 for the following resources.
Can you use Firebug and paste the HTTP response headers. I have a feeling that even though in your code you are setting cache control to Public, Apache is overriding that because for Php File type you are setting Cache-Control to private.
One thing you can do it remove the cache settings for Dynamic Pages from Apache configuration. That should fix the problem because a Proxy doesn't cache a response without the correct headers.
EDIT
Hi Sam, Revisiting you question I found the solution to the problem. The following code snippet appears to be a problem. In the output of your Php the Last-Modified header always changes and when a browser sends a 304 If modified request it see a change and therefore re-requests that content.
Unset Last-Modified and ETags from your content to speed up the website. This site provides some excellent tips too.
http://www.askapache.com/htaccess/apache-speed-last-modified.html
I added the following code in my htaccess file when http://pagespeed.googlelabs.com/ in chrome I got Leverage browser caching which is now solved but now it gives error of Specify a cache validator, how to do it else I have already added cache controls, below is the code