close

May 2024 only! Join our Discord free of charge.

Slick­Stack
Lightning-fast WordPress on Nginx

Cache TTL policy for fonts and JS

  • This topic is empty.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #24866 Reply
    Cheryl
    Guest

    Hi,

    The cache lifetime for fonts, JS and css is 0 days. This results in slow page for repeat users, why is that so?

    Also, suggestions please how can i fix this?

    Regards

    #24869 Reply
    Andrew
    Guest

    are you using Cloudflare OP?

    #24879 Reply
    Elizabeth
    Guest

    Sorry, what is cloudflare OP?
    (Yes My domain is on Cloudflare, though.)

    #24880 Reply
    Amanda
    Guest

    https://github.com/littlebizzy/slickstack/blob/master/modules/nginx/sites/production.txt

    <blockquote>location ~* \.(css|eot|js|otf|svg|ttc|ttf|woff|woff2)$ {
    	set $cachecontrol "public, max-age=15778476"; ## 6 months
    	set $setcookie "";
    	add_header Access-Control-Allow-Origin "*";
    }</blockquote>

    It’s set to 6 months in SlickStack

    #24882 Reply
    Eugene
    Guest

    Thankyou for code snippet I’ll check my nginx config.

    But Why on god’s green earth my domain page speed insights gives me error on this!

    Please have a look here: https://pagespeed.web.dev/analysis/https-tryfunky-com-shop-the-american-muscle-oversize-tee-for-men/c6uo789ank?form_factor=mobile

    #24890 Reply
    Dennis
    Guest

    I checked, that block is present in my nginx conf. Still pagespeed keeps on saying that. Any clue?

    #24891 Reply
    Randy
    Guest
    #24897 Reply
    Bruce
    Guest

    That helped. I modified the production.conf to fix this, also tweaked some settings on Cloudflare. Thanks a ton!

    #24899 Reply
    Patricia
    Guest

    That helped. I modified the production.conf to fix this, also tweaked some settings on Cloudflare. Thanks a ton!

    please share details otherwise it doesn’t help anyone!

    #24929 Reply
    Judy
    Guest

    Absolutely, my bad. Here is the tweak I did.

    ####### AVOIDS MATCHING MULTIPLE LOCATION BLOCKS ###########

    location ~* \.(eot|otf|svg|ttc|ttf|woff|woff2|svgz|js|css)$ {
    expires 6M;
    add_header Cache-Control “public, max-age=15778476”;
    add_header Access-Control-Allow-Origin “*”;
    add_header Pragma public;
    add_header Vary Accept-Encoding;
    add_header Content-Security-Policy “default-src ‘self’; script-src ‘self’; style-src ‘self’; font-src ‘self’ data:; img-src ‘self’ data:; connect-src ‘self’; frame-ancestors ‘self’;”;
    add_header X-Frame-Options “SAMEORIGIN”;
    add_header X-Content-Type-Options “nosniff”;
    add_header Referrer-Policy “no-referrer-when-downgrade”;
    add_header Permissions-Policy “geolocation=(), midi=(), notifications=(), push=(), sync-xhr=(), magnetometer=(), gyroscope=(), speaker=(), vibrate=(), fullscreen=(), payment=()”;
    access_log off;
    try_files $uri =404;
    }

    ## stupid idea lets disable for now ##

    This solved my problem.

    There is a blog that says instead of putting geolocation=() try geolocation=(self “https://example.com&#8221;) but that gave me nginx conf error…

    Open for suggestions.

Viewing 10 posts - 1 through 10 (of 10 total)
Reply To: Cache TTL policy for fonts and JS

Thanks to our generous sponsors for their support!