• Resolved Adelyn

    (@matildarose)


    Hi everyone. Finally, after two years of page speed tests telling me to leverage browser caching, I understand what it means and I’m comfortable enough to give it a try. I need a little help, though.

    Right now I’m using the “expires” method, and this is the code I have in place in .htacces:

    ## LEVERAGE BROWSER CACHING ##
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/gif "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/pdf "access plus 1 month"
    ExpiresByType application/x-javascript "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 month"
    ExpiresByType application/x-shockwave-flash "access plus 1 month"
    ExpiresByType image/x-icon "access plus 1 year"
    ExpiresByType application/x-font-woff "access plus 1 weeks"
    ExpiresDefault "access plus 2 days"
    </IfModule>
    ## LEVERAGE BROWSER CACHING ##

    My first question is, do I need the word “plus” or not? In the examples I’ve come across, I’ve see it with and without the “plus.” Which is correct?

    Also, I’m reading that using the cache-control method might be better. Would this be correct:

    # 1 Month for most static assets
    <filesMatch ".(css|jpg|jpeg|png|gif|js|ico)$">
    Header set Cache-Control "max-age=2592000, public"
    </filesMatch>

    If I use cache-control, should I delete the “expires” code?

    Another question: How do I ensure that pages are updated in browsers after making changes to style.css, for example?

    My website is https://psychopathsandlove.com/invalidation/

    Thank you very much for your help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Adelyn

    (@matildarose)

    I have added this to .htaccess:

    ## 1 Month for most static assets ##
    <FilesMatch "\.(json|pdf|swf|bmp|gif|jpeg|jpg|png|svg|tiff|ico|flv|css|js)$">
    Header set Cache-Control "max-age=2592000, public"
    </filesMatch>
    ## END 1 month for most static assets ##

    I’ve just learned that max-age will enable the browser to check for updated files. Is that correct?

    I’ve seen other examples of this code that include this:

    <IfModule mod_headers.c>

    Is that necessary?

    Thank you

    Thread Starter Adelyn

    (@matildarose)

    The code works!!

    I’m leaving this follow-up in case anyone else comes along needing help with the same issue.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Leveraging Browser Caching: Expires vs Cache Control?’ is closed to new replies.