Cloudflare cache

Hey! How exactly should I set up my cache rules so it caches "more" and better?
No description
89 Replies
Chaika
Chaikaβ€’9mo ago
It really depends on your setup. It's saying there you have some static assets that could be cached longer. You could just have your origin return Cache-Control headers with longer ttls, or you can use Cache Rules to override that. If your website fully static? Do you have dynamic parts of it? Can your dynamic parts be cached for any amount of time at all? etc
NoFi
NoFiOPβ€’9mo ago
Oh, so it's only about the caching length?
NoFi
NoFiOPβ€’9mo ago
I set that, is it bad or good or what's up?
No description
Chaika
Chaikaβ€’9mo ago
That warning is just about length yea
NoFi
NoFiOPβ€’9mo ago
Can I optimize it any further?
Chaika
Chaikaβ€’9mo ago
It really depends on your web application. That is pretty excessively long though, I would recommend a shorter browser cache ttl (day or two max) and longer Edge Cache TTLs
NoFi
NoFiOPβ€’9mo ago
longer Edge Cache TTLs ?
Chaika
Chaikaβ€’9mo ago
Yea, how long Cloudflare will keep it on edge on their edge
NoFi
NoFiOPβ€’9mo ago
And why is it a bad idea to have that long browser cache ttl?
Chaika
Chaikaβ€’9mo ago
If you change an asset and a client has a super long browser cache ttl, client won't see that change, for up to a year
NoFi
NoFiOPβ€’9mo ago
ohh But I have it set to 1 year and When I make a change and refresh, I can see it
Chaika
Chaikaβ€’9mo ago
This is sometimes ok if you are versioning assets by name, like if your css is {sha1}.css, so on any change it'd be a new cache key anyway, but if you are using static file names then less ok
NoFi
NoFiOPβ€’9mo ago
It's an online store, made using sellix.io
Chaika
Chaikaβ€’9mo ago
that is really vague. What change did you do? Is it from the website doing a fetch request? Is it from a site update on a versioned resource, etc
NoFi
NoFiOPβ€’9mo ago
I'm not a dev, i have no idea
Chaika
Chaikaβ€’9mo ago
then I wouldn't play with it. If it's an online store you want to be really careful with what you're caching
NoFi
NoFiOPβ€’9mo ago
Yea, but I'd like to speed up my website
Chaika
Chaikaβ€’9mo ago
Efficient cache policies will only really help on repeat visitors, and only by a marginal amount. If you're using a platform already, trust the cache headers they are returning, and change browser cache ttl to Respect Existing headers
NoFi
NoFiOPβ€’9mo ago
So... no cache? How about the 1 or 2 day browser cache ttl?
Chaika
Chaikaβ€’9mo ago
It's way too hard to tell without knowing more about the website itself. There is already some browser cache for you go have got that warning. The platform you are using is returning Cache-Control headers with an age they think is appropriate. If you override it, and they do a change to a specific js file or something to fix a critical issue, you may not see it for longer then they would expect on your website.
NoFi
NoFiOPβ€’9mo ago
I can send you a website link if it helps
Chaika
Chaikaβ€’9mo ago
All that warning is Cloudflare saying "hey you have some static assets that could have a longer cache, we think" Sure
NoFi
NoFiOPβ€’9mo ago
So in this specific case, what should I do about the cache?
Chaika
Chaikaβ€’9mo ago
Cloudflare speed test under the hood is just using Google's pagespeed test, so we can get more info there: https://pagespeed.web.dev/analysis/https-gamingchairservices-com/a7nwp3ezni?form_factor=mobile
NoFi
NoFiOPβ€’9mo ago
I see, but I'd like to set up the cache thing first
Chaika
Chaikaβ€’9mo ago
it looks like all of the assets it cares about having efficient cache policies are ones you do not have control over
No description
NoFi
NoFiOPβ€’9mo ago
Oh, okay So what do I do on my end?
Chaika
Chaikaβ€’9mo ago
all the ones under your site are under challenge platform, zaraz, or rocket loader
NoFi
NoFiOPβ€’9mo ago
mhm
Chaika
Chaikaβ€’9mo ago
Did you set back the Browser Cache TTL to Respect Existing headers? Could rerun with that, it looks most of the assets are coming from sellex's domain
NoFi
NoFiOPβ€’9mo ago
Right now browser cache ttl is set to 2 days
Chaika
Chaikaβ€’9mo ago
eh those are minor anyway though, the big issue with your site is main thread work/javascript execution time
NoFi
NoFiOPβ€’9mo ago
So do I change it back to Respect Existing headers? Or what do I do? I'd prefer to take care of one thing first before proceeding to the other
Chaika
Chaikaβ€’9mo ago
I would yea, just to make sure it won't mess with anything in the future.
NoFi
NoFiOPβ€’9mo ago
But it means that it won't cache as much and be slower, right? "Determine the length of time Cloudflare instructs a visitor’s browser to cache files. During this period, the browser loads the files from its local cache, speeding up page loads."
Chaika
Chaikaβ€’9mo ago
Right now, all of the static assets are coming from sellx's domain and not yours
No description
Chaika
Chaikaβ€’9mo ago
I would just set that back so you don't mess up something in the future and confuse yourself
NoFi
NoFiOPβ€’9mo ago
Oh okay So it doesn't slow anything down πŸ˜‚
Chaika
Chaikaβ€’9mo ago
Respect Existing Header does not mean no cache, it just means use the existing ones
NoFi
NoFiOPβ€’9mo ago
πŸ‘Œ What's the next thing I should work on within cloudflare?
Chaika
Chaikaβ€’9mo ago
Your biggest issue is just sellx itself
No description
Chaika
Chaikaβ€’9mo ago
Lots of Javascript, slow response time for root page at times
Chaika
Chaikaβ€’9mo ago
Mobile Analysis by Pagespeed just says the same basically
No description
NoFi
NoFiOPβ€’9mo ago
Is there anything I can do about it in cloudflare?
Chaika
Chaikaβ€’9mo ago
There are some things but I wouldn't expect too much magic, CF can only do so much when the site is serving a ton of javascript that is just slow
NoFi
NoFiOPβ€’9mo ago
Alright, let's do what we can do πŸ˜‰
Chaika
Chaikaβ€’9mo ago
Under Speed -> Optimization -> Content Optimization, make sure Auto Minify is on. You could also try turning Rocket Loader off, under that same section, it tries to help but sometimes can do more hurting them helping/makes it harder to see what exactly is slow
NoFi
NoFiOPβ€’9mo ago
Rocket Loader is off, as with it on, my site is getting broken
Chaika
Chaikaβ€’9mo ago
yea that's rocket loader for you. Is it off though? I still see it
No description
NoFi
NoFiOPβ€’9mo ago
No description
NoFi
NoFiOPβ€’9mo ago
looks off to me when I enable it, the site is broken
NoFi
NoFiOPβ€’9mo ago
and auto minify is enabled
No description
Chaika
Chaikaβ€’9mo ago
oh sellx is using Cloudflare, it's from their configuration
NoFi
NoFiOPβ€’9mo ago
odd but probably
Chaika
Chaikaβ€’9mo ago
Looks like you are using both Google Tag Manager and CF Web Analytics, not sure if purposeful or forced from them. GTM is kind of slow
NoFi
NoFiOPβ€’9mo ago
Hmm Is it the thing where I put the tracking ID?
Chaika
Chaikaβ€’9mo ago
Yea, GTM does need a tracking id
NoFi
NoFiOPβ€’9mo ago
I have the option to use that thing in sellix AND in cloudflare there's a similar thing I think I have both enabled πŸ˜‚ Which one do I disable?
Chaika
Chaikaβ€’9mo ago
You do have both Web Analytics & GTM Some people want both, it's up to you. CF Web Analytics is lighter and more privacy respecting. Google Tag Manager/Analytics is less privacy respecting but way more analytics
NoFi
NoFiOPβ€’9mo ago
I'd stick to CF then So to get rid of google's what do I do? disable it in sellix?
NoFi
NoFiOPβ€’9mo ago
No description
Chaika
Chaikaβ€’9mo ago
Yea disable it there
NoFi
NoFiOPβ€’9mo ago
done can you see if it got disabled in the speed thing?
Chaika
Chaikaβ€’9mo ago
Sure. Under Speed -> Optimization, do you have everything that isn't Upgrade required on? Focused mostly on HTTP/3, 0-Rtt Connection Resumption, and Early Hints can be nice as well
NoFi
NoFiOPβ€’9mo ago
Yes, everything but rocket loader
Chaika
Chaikaβ€’9mo ago
yea GTM is gone. Your score went from 36 on mobile -> 46, 91 -> 94 on desktop. That's something
NoFi
NoFiOPβ€’9mo ago
That's pretty good
Chaika
Chaikaβ€’9mo ago
Other then that though, your options are kind of limited. You could try CF Argo Smart Routing for better origin connection/improves inbound connection routing as well, but it's $5/month + $0.10 per gigabyte used, and might not help too much depending on sellx. You have a few unoptimized images, but they're from sellx's domain so you can't touch them. Does sellx have any options to use other themes/optimize assets? It is pretty high, ~5.56mb of assets uncompressed and 172 requests, some ~59 JS files and ~66 css files
NoFi
NoFiOPβ€’9mo ago
Can I limit agro to like $10 a month, so no matter what happens I don't pay more?
Chaika
Chaikaβ€’9mo ago
Sadly no, you can add billing alerts though.
NoFi
NoFiOPβ€’9mo ago
I don't want to wake up one day with a $1000 bill
Chaika
Chaikaβ€’9mo ago
Argo gives you Enterprise like inbound routing, which can help a lot in Asia-Pacific region if you've got a lot of visitors from there, and help reduce origin connection. But if your origin is just slow at generating the page, which it seems to be, it can only help so much.
NoFi
NoFiOPβ€’9mo ago
I see What do you mean by unoptimized images? I can upload my own to sellix, that's why they're showing up as theirs
Chaika
Chaikaβ€’9mo ago
looks like just two: https://cdn-theme.mysellix.io/shops/360225/themes/115895/728c7f31b2790d8654191a123734794365fd648171078.png is slightly unoptimized/could be made smaller. It's sized pretty big for what it a tiny image is in the top left. https://cdn-theme.mysellix.io/shops/360225/themes/115895/20acfcc60dc2a53b1eba4f568044e18e65fd69b242cf7.jpg is in an unoptimized format. They've got Cloudflare Polish on to optimize images on their own site but looks like not converting them to webp
NoFi
NoFiOPβ€’9mo ago
Oh, these are mine
Chaika
Chaikaβ€’9mo ago
Your bigger issue is the theme thuogh
Does sellx have any options to use other themes/optimize assets? It is pretty high, ~5.56mb of assets uncompressed and 172 requests, some ~59 JS files and ~66 css files
It looks like you can make custom themes. Any way to have them be more optimized/clean them up?
NoFi
NoFiOPβ€’9mo ago
Probably yes I'll take care of the images first
NoFi
NoFiOPβ€’9mo ago
I can only upload these file formats
No description
NoFi
NoFiOPβ€’9mo ago
Which one should I use?
Chaika
Chaikaβ€’9mo ago
jpeg is compressable and generally smaller. png is loseless/preserves image quality
NoFi
NoFiOPβ€’9mo ago
Which one should I go for the logo?
Chaika
Chaikaβ€’9mo ago
can just use png, I would just run it through some compression tool/resize it a bit smaller. It doesn't need to be 1000x100x if it's only shown in 30x30 in the header
NoFi
NoFiOPβ€’9mo ago
So Like 64x64 would be good? or 128x?
Chaika
Chaikaβ€’9mo ago
Sure, either of those are reasonable. You are forcing the size to 30 height max always, won't get much bigger
NoFi
NoFiOPβ€’9mo ago
on a 4k screen it would be 4x that, right?
Chaika
Chaikaβ€’9mo ago
nah, you're forcing it to a max of 30 pixels heigh everywhere
NoFi
NoFiOPβ€’9mo ago
Oh So 30x is okay? It looks much worse now What's wrong? I made it 30x30 I just made it 90x90, looks better well, still bad I don't get it
Chaika
Chaikaβ€’9mo ago
It's not going to be bigger on a bigger screen, but removing too many pixels will still make it grainy, plus I assume you're running it through a compresser/optimizer of some sort
NoFi
NoFiOPβ€’9mo ago
Alright, I used a different resizing tool and made it 180x180, looks better now. Can you check it on your end? And also performance wise if it's optimized now Compressed the 2nd image as well @Chaika? @Chaika πŸ‘€
Want results from more Discord servers?
Add your server