Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Mar 2009
    Posts
    116
    Thanks
    29
    Thanked 1 Time in 1 Post

    Caching not working.

    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....


    Code:
    #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.
    Last edited by hernantz; 09-29-2010 at 04:18 PM.

  • #2
    Regular Coder
    Join Date
    Jun 2010
    Posts
    132
    Thanks
    8
    Thanked 0 Times in 0 Posts

  • #3
    Regular Coder
    Join Date
    Mar 2009
    Posts
    116
    Thanks
    29
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Tony M View Post
    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
    Im showing the css file results, but it is the same with img and js files.





    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

  • #4
    Regular Coder
    Join Date
    Mar 2009
    Posts
    116
    Thanks
    29
    Thanked 1 Time in 1 Post
    Ok it is working

    The code ended up like this

    Code:
    # 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!

    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.
    Last edited by hernantz; 10-05-2010 at 06:13 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •