1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to disable caching with .htaccess?

Discussion in 'Cloaking and Content Generators' started by SeoQuest, Dec 25, 2012.

  1. SeoQuest

    SeoQuest Junior Member

    Joined:
    Jun 24, 2012
    Messages:
    141
    Likes Received:
    41
    Location:
    Europe
    I want to disable page caching from google and other search engines using .htaccess. Does anyone know what code should i use in the .htaccess file to disable caching?
     
  2. TZ2011

    TZ2011 Senior Member

    Joined:
    Jun 26, 2011
    Messages:
    832
    Likes Received:
    861
    Occupation:
    Cleaning servers
    Code:
    <filesMatch "\.(html|htm|txt|js)$">
    FileETag None
    <ifModule mod_headers.c>
    Header unset ETag
    Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
    Header set Pragma "no-cache"
    Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
    </ifModule>
    </filesMatch>
    
    Also if you want to gzip (compress) pages for faster loading, you can use this

    Code:
    <ifModule mod_deflate.c>
      <filesMatch "\.(css|js|x?html?|php)$">
        SetOutputFilter DEFLATE
      </filesMatch>
    </ifModule>
    
    
    
     
    • Thanks Thanks x 1
    Last edited: Dec 25, 2012