Cache TTL policy for fonts and JS
- This topic is empty.
-
AuthorPosts
-
May 15, 2024 at 10:46 am #24866CherylGuest
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
May 15, 2024 at 12:36 pm #24869AndrewGuestare you using Cloudflare OP?
May 15, 2024 at 5:39 pm #24879ElizabethGuestSorry, what is cloudflare OP?
(Yes My domain is on Cloudflare, though.)May 15, 2024 at 5:43 pm #24880AmandaGuesthttps://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
May 15, 2024 at 5:53 pm #24882EugeneGuestThankyou 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
May 16, 2024 at 5:40 pm #24890DennisGuestI checked, that block is present in my nginx conf. Still pagespeed keeps on saying that. Any clue?
May 17, 2024 at 5:21 am #24891RandyGuesthmm
we might need to investigate this, seems like the headers might have gotten broken
May 17, 2024 at 12:09 pm #24897BruceGuestThat helped. I modified the production.conf to fix this, also tweaked some settings on Cloudflare. Thanks a ton!
May 17, 2024 at 1:41 pm #24899PatriciaGuestThat 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!
May 18, 2024 at 4:46 pm #24929JudyGuestAbsolutely, 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”) but that gave me nginx conf error…
Open for suggestions.
-
AuthorPosts