...

View Full Version : Caching not working.



hernantz
09-29-2010, 02:13 AM
Hi there, i have wampserver set up with mod_expire and mod_headers eneabled.

I've put this into a .htaccess file but when running the google chrome's page speed test it says that i have to Leverage browser caching (6) on some images, css, javascript files that seem to be lacking of an expiration time....



#BEGIN OF CACHING
ExpiresActive On
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
#END OF CACHING

Any idea is welcome, thanks in advance.

Tony M
10-02-2010, 05:00 AM
Ok, I think this page may help You http://www.php.net/manual/en/function.header.php#77028 and also http://httpd.apache.org/docs/2.0/mod/mod_expires.html :thumbsup:

hernantz
10-05-2010, 02:30 AM
Ok, I think this page may help You http://www.php.net/manual/en/function.header.php#77028 and also http://httpd.apache.org/docs/2.0/mod/mod_expires.html :thumbsup:

Hi, thanks for your interest and suggestions.

I dont really know if it is working, it seems it does becouse i've looked into firebug speedtest suggestions and it says i may want to consider extending cache expiration to one week for some files/images becouse in may htacces file i put 2 hours just for testing porpouses.

But whats the diference between Request headers and Response headers

here i attach an image of my results :D
Im showing the css file results, but it is the same with img and js files.


http://img812.imageshack.us/img812/3106/headersx.png (http://img812.imageshack.us/i/headersx.png/)


In request headers it says Cache-control: no-cache.
And in response headers it says: Cache-control: max-age=7200, private, must-revalidate

Is is working or not?

Thanks

hernantz
10-05-2010, 06:08 PM
Ok it is working

The code ended up like this


# Turn on Expires and set default to 0
ExpiresActive On
ExpiresDefault A0

# Set up caching on media files for 1 year (forever?)
<FilesMatch "\.(ico|flv|pdf|mov|mp3|wmv|ppt)$">
ExpiresDefault A29030400
Header append Cache-Control "public"
</FilesMatch>

# Set up caching on media files for 1 week
<FilesMatch "\.(gif|jpg|jpeg|png|swf)$">
ExpiresDefault A604800
Header append Cache-Control "public, proxy-revalidate"
</FilesMatch>

# Set up 2 Hour caching on commonly updated files
<FilesMatch "\.(xml|txt|html|js|css)$">
ExpiresDefault A7200
Header append Cache-Control "private, proxy-revalidate, must-revalidate"
</FilesMatch>

# Force no caching for dynamic files
<FilesMatch "\.(php|cgi|pl|htm)$">
ExpiresDefault A0
Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, no-transform"
Header set Pragma "no-cache"
</FilesMatch>

Source: Speeding up your sites with caching! (http://codingforums.com/showthread.php?t=105355)

About the response and request headers, i've looked at some big sites such as yahoo and youtube that have the same i showed on the image above.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum