• Hi.

    I would like to set the browser cache expiration on the “index.html” homepage to “0“.

    And the rest of the html files in 1 week.

    I tried to do it via htaccess using the code below

    <IfModule mod_expires.c>
    # Enable expirations
    ExpiresActive On 
    # Default directive
    ExpiresDefault "access plus 1 month"
    
    ExpiresByType text/html "access plus 1 week"
        <FilesMatch "^(index\.html)$">
            ExpiresActive On
            ExpiresByType text/html "access plus 0 seconds"
            Header append Cache-Control "public"
        </FilesMatch>
    </IfModule>

    But only a week’s setup works:
    ExpiresByType text/html "access plus 1 week"

    This setting inside “FilesMatch” is completely ignored.
    ExpiresByType text / html "access plus 0 seconds"

    However, when I try to disable the caching of the styles.css file instead of index.html, the code works.

    It seems to be something related to the html type when it is inside “FilesMatch”

    Can anyone help me with this?

    • This topic was modified 2 years, 12 months ago by delaitec.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Is this a WordPress site? There’s no index.html end-point. Try to visit the index.html for your domain in the browser. Chances are you’ll get 404, unless you’re doing some redirection yourself (or your caching plugin is serving an index.html file for the homepage).

    Thread Starter delaitec

    (@delaitec)

    Hello George

    thanks for your help.

    Yes it is a wordpress site,

    So, as it does not have an index.html file, how should I set the headers expiration to zero, only on the homepage?

    I need the browser not to cache the html only on the home page. because it always changes.

    Try index.php, or even just /

    Thread Starter delaitec

    (@delaitec)

    I thought about using, index.php, and even tested it, but it doesn’t work. because the index.php file is on the server it is not sent to the browser.

    He is the one who generates the html files.

    And I already did the test, the files are sent to the browser in HTML, because when I set the duration of the HTML to 0 seconds, the browser does not save the cache.

    I even thought of testing / but don’t know how to write the code, since / it is not a file, and FilesMatch, as the name says, affects files.

    The whole question is how to apply only in the Homepage.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to disable caching only on the homepage’ is closed to new replies.