Results 1 to 7 of 7

Thread: browser caching .htaccess

  1. #1
    Join Date
    Sep 2004
    Location
    Johannesburg, South Africa
    Posts
    383
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default browser caching .htaccess

    Hi Guys & Girls


    I'm trying to make browser caching work on a website, I think I followed all the rules with my .htaccess file (below) and report of what tester say below that....

    Any idea what I'm doing incorrectly??

    Thanks in advance....

    .htaccess file content:
    __________________________________________________
    ## EXPIRES CACHING ##
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access 1 month"
    ExpiresByType image/jpeg "access 1 year"
    ExpiresByType image/gif "access 1 year"
    ExpiresByType image/png "access 1 year"
    ExpiresByType text/css "access 1 month"
    ExpiresByType text/html "access 1 month"
    ExpiresByType application/pdf "access 1 month"
    ExpiresByType text/x-javascript "access 1 month"
    ExpiresByType application/x-shockwave-flash "access 1 month"
    ExpiresByType image/x-icon "access 1 year"
    ExpiresDefault "access 1 month"
    </IfModule>
    ## EXPIRES CACHING ##

    ErrorDocument 404 http://www.silvertreeestates.co.za/404page.html
    __________________________________________________

    But when testing site, it still says:

    "Expiration not specified" for all files.

    [MOD EDIT] large repetitive code dump removed
    Last edited by Beverleyh; 10-29-2016 at 02:02 PM. Reason: Large repetitive code dump removed
    Very Best Rgds, Simonf :cool:
    __________________________________
    My Site | E-Mail Me | RSA Search Engine

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,007
    Thanks
    25
    Thanked 587 Times in 566 Posts
    Blog Entries
    37

    Default

    Looks like a syntax error - try "access plus 1 year" (or whatever).
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  3. The Following User Says Thank You to Beverleyh For This Useful Post:

    simonf (10-29-2016)

  4. #3
    Join Date
    Sep 2004
    Location
    Johannesburg, South Africa
    Posts
    383
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    HI Beverley

    Tried that, still the same.... confusing me like hell....
    Very Best Rgds, Simonf :cool:
    __________________________________
    My Site | E-Mail Me | RSA Search Engine

  5. #4
    Join Date
    Nov 2014
    Location
    On A Scottish Island
    Posts
    326
    Thanks
    0
    Thanked 41 Times in 38 Posts

    Default

    This page implies that the time keywords for .htaccess should be plural (years, months, days etc.), however the comments at the end say that either singular or plural are acceptable. It might be worth trying the plurals.

  6. #5
    Join Date
    Sep 2004
    Location
    Johannesburg, South Africa
    Posts
    383
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    HI Styxlawyer... tried that... to no avail, even tried the following which should also work to no avail....

    Anymore suggestions people.....


    Code:
    ##############################################
    # Expire headers
    <ifModule mod_expires.c>
      ExpiresActive On
      ExpiresDefault "modification plus 1 seconds"
      ExpiresByType image/x-icon "modification plus 1 week"
      ExpiresByType image/jpeg "modification plus 1 week"
      ExpiresByType image/png "modification plus 1 week"
      ExpiresByType image/gif "modification plus 1 week"
      ExpiresByType application/x-shockwave-flash "modification plus 1 week"
      ExpiresByType text/css "modification plus 1 week"
      ExpiresByType text/javascript "modification plus 1 week"
      ExpiresByType application/javascript "modification plus 1 week"
      ExpiresByType application/x-javascript "modification plus 1 week"
      ExpiresByType text/html "modification plus 1 week"
      ExpiresByType application/xhtml+xml "modification plus 600 seconds"
    </ifModule>
     
    # Cache-Control Headers
    <ifModule mod_headers.c>
    #month
      <filesMatch "\.(ico|jpe?g|png|gif|swf)$">
        Header set Cache-Control "max-age=2592000, public"
      </filesMatch>
    #week
      <filesMatch "\.(css|js)$">
        Header set Cache-Control "max-age=604800, public"
      </filesMatch>
    #day
      <filesMatch "\.(x?html?|php)$">
        Header set Cache-Control "max-age=43200, private, must-revalidate"
      </filesMatch>
    </ifModule>
    # END Cache-Control Headers
     
    # Turn ETags Off
    <ifModule mod_headers.c>
      Header unset ETag
    </ifModule>
    FileETag None
     
    # Remove Last-Modified Header
    <ifModule mod_headers.c>
      Header unset Last-Modified
    </ifModule>
    
    ErrorDocument 404 http://www.silvertreeestates.co.za/404page.html
    ##############################################
    Last edited by Beverleyh; 10-30-2016 at 04:15 PM. Reason: Formatting
    Very Best Rgds, Simonf :cool:
    __________________________________
    My Site | E-Mail Me | RSA Search Engine

  7. #6
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,007
    Thanks
    25
    Thanked 587 Times in 566 Posts
    Blog Entries
    37

    Default

    Note from Mod : Don't forget to format your code using the # button in the toolbar.

    Have you checked if mod_expires is enabled on the server? You can do that by taking out the opening and closing <ifModule> tags and changing the syntax back to "access plus 1 year" etc. If the server reports a 500 error, the module might not even be installed so you should ask your web host to enable it.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  8. The Following User Says Thank You to Beverleyh For This Useful Post:

    simonf (10-31-2016)

  9. #7
    Join Date
    Sep 2004
    Location
    Johannesburg, South Africa
    Posts
    383
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    HI Beverley

    Thanks for the input the other day re being enabled on the server on my ISP, they moved my site to another server and it seems to work now with the following code below.

    But I'm still not finished as on smart phones, this does not show as working.... any suggestion you bright lovely people out there

    Code:
    <ifModule mod_expires.c>
      ExpiresActive On
      ExpiresDefault "modification plus 1 seconds"
      ExpiresByType image/x-icon "modification plus 1 week"
      ExpiresByType image/jpeg "modification plus 1 week"
      ExpiresByType image/png "modification plus 1 week"
      ExpiresByType image/gif "modification plus 1 week"
      ExpiresByType application/x-shockwave-flash "modification plus 1 week"
      ExpiresByType text/css "modification plus 1 week"
      ExpiresByType text/javascript "modification plus 1 week"
      ExpiresByType application/javascript "modification plus 1 week"
      ExpiresByType application/x-javascript "modification plus 1 week"
      ExpiresByType text/html "modification plus 1 week"
      ExpiresByType application/xhtml+xml "modification plus 600 seconds"
    </ifModule>
     
    # Cache-Control Headers
    <ifModule mod_headers.c>
    #month
      <filesMatch "\.(ico|jpe?g|png|gif|swf)$">
        Header set Cache-Control "max-age=2592000, public"
      </filesMatch>
    #week
      <filesMatch "\.(css|js)$">
        Header set Cache-Control "max-age=604800, public"
      </filesMatch>
    #day
      <filesMatch "\.(x?html?|php)$">
        Header set Cache-Control "max-age=43200, private, must-revalidate"
      </filesMatch>
    </ifModule>
    # END Cache-Control Headers
     
    # Turn ETags Off
    <ifModule mod_headers.c>
      Header unset ETag
    </ifModule>
    FileETag None
     
    # Remove Last-Modified Header
    <ifModule mod_headers.c>
      Header unset Last-Modified
    </ifModule>
    
    # compress text, html, javascript, css, xml:
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    
    # Or, compress certain file types by extension:
    <files *.html>
    SetOutputFilter DEFLATE
    </files>
    
    ErrorDocument 404 http://www.silvertreeestates.co.za/404page.html
    Very Best Rgds, Simonf :cool:
    __________________________________
    My Site | E-Mail Me | RSA Search Engine

Similar Threads

  1. Prevent Browser Caching
    By sdo in forum Flash
    Replies: 0
    Last Post: 02-10-2010, 07:49 PM
  2. Iframe src url caching
    By monn_dg in forum JavaScript
    Replies: 1
    Last Post: 03-25-2009, 12:37 PM
  3. Browser Caching Problem
    By stephenalistoun in forum JavaScript
    Replies: 2
    Last Post: 01-02-2009, 05:02 PM
  4. ajaxcontent caching
    By itKiwi in forum Dynamic Drive scripts help
    Replies: 5
    Last Post: 03-18-2006, 05:49 PM
  5. Images + caching
    By holobyted in forum PHP
    Replies: 6
    Last Post: 07-12-2005, 07:10 PM

Tags for this Thread

Bookmarks

Posting Permissions

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