Cloudflare cache

Hey! How exactly should I set up my cache rules so it caches "more" and better?
No description
92 Replies
Chaika
Chaikaβ€’3mo 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
NoFiβ€’3mo ago
Oh, so it's only about the caching length?
NoFi
NoFiβ€’3mo ago
I set that, is it bad or good or what's up?
No description
Chaika
Chaikaβ€’3mo ago
That warning is just about length yea
NoFi
NoFiβ€’3mo ago
Can I optimize it any further?
Chaika
Chaikaβ€’3mo 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
NoFiβ€’3mo ago
longer Edge Cache TTLs ?
Chaika
Chaikaβ€’3mo ago
Yea, how long Cloudflare will keep it on edge on their edge
NoFi
NoFiβ€’3mo ago
And why is it a bad idea to have that long browser cache ttl?
Chaika
Chaikaβ€’3mo 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
NoFiβ€’3mo ago
ohh But I have it set to 1 year and When I make a change and refresh, I can see it
Chaika
Chaikaβ€’3mo 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
NoFiβ€’3mo ago
It's an online store, made using sellix.io
Chaika
Chaikaβ€’3mo 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
NoFiβ€’3mo ago
I'm not a dev, i have no idea
Chaika
Chaikaβ€’3mo 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
NoFiβ€’3mo ago
Yea, but I'd like to speed up my website
Chaika
Chaikaβ€’3mo 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
NoFiβ€’3mo ago
So... no cache? How about the 1 or 2 day browser cache ttl?
Chaika
Chaikaβ€’3mo 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
NoFiβ€’3mo ago
I can send you a website link if it helps
Chaika
Chaikaβ€’3mo ago
All that warning is Cloudflare saying "hey you have some static assets that could have a longer cache, we think" Sure
NoFi
NoFiβ€’3mo ago
https://gamingchairservices.com/ So in this specific case, what should I do about the cache?
Chaika
Chaikaβ€’3mo 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
NoFiβ€’3mo ago
I see, but I'd like to set up the cache thing first
Chaika
Chaikaβ€’3mo 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
NoFiβ€’3mo ago
Oh, okay So what do I do on my end?
Chaika
Chaikaβ€’3mo ago
all the ones under your site are under challenge platform, zaraz, or rocket loader
NoFi
NoFiβ€’3mo ago
mhm
Chaika
Chaikaβ€’3mo 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
NoFiβ€’3mo ago
Right now browser cache ttl is set to 2 days
Chaika
Chaikaβ€’3mo ago
eh those are minor anyway though, the big issue with your site is main thread work/javascript execution time
NoFi
NoFiβ€’3mo 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β€’3mo ago
I would yea, just to make sure it won't mess with anything in the future.
NoFi
NoFiβ€’3mo 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β€’3mo ago
Right now, all of the static assets are coming from sellx's domain and not yours
No description
Chaika
Chaikaβ€’3mo ago
I would just set that back so you don't mess up something in the future and confuse yourself
NoFi
NoFiβ€’3mo ago
Oh okay So it doesn't slow anything down πŸ˜‚
Chaika
Chaikaβ€’3mo ago
Respect Existing Header does not mean no cache, it just means use the existing ones
NoFi
NoFiβ€’3mo ago
πŸ‘Œ What's the next thing I should work on within cloudflare?
Chaika
Chaikaβ€’3mo ago
Your biggest issue is just sellx itself
No description
Chaika
Chaikaβ€’3mo ago
Lots of Javascript, slow response time for root page at times
Chaika
Chaikaβ€’3mo ago
Mobile Analysis by Pagespeed just says the same basically
No description
NoFi
NoFiβ€’3mo ago
Is there anything I can do about it in cloudflare?
Chaika
Chaikaβ€’3mo 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
NoFiβ€’3mo ago
Alright, let's do what we can do πŸ˜‰
Chaika
Chaikaβ€’3mo 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
NoFiβ€’3mo ago
Rocket Loader is off, as with it on, my site is getting broken
Chaika
Chaikaβ€’3mo ago
yea that's rocket loader for you. Is it off though? I still see it
No description
NoFi
NoFiβ€’3mo ago
No description
NoFi
NoFiβ€’3mo ago
looks off to me when I enable it, the site is broken
NoFi
NoFiβ€’3mo ago
and auto minify is enabled
No description
Chaika
Chaikaβ€’3mo ago
oh sellx is using Cloudflare, it's from their configuration
NoFi
NoFiβ€’3mo ago
odd but probably
Chaika
Chaikaβ€’3mo 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
NoFiβ€’3mo ago
Hmm Is it the thing where I put the tracking ID?
Chaika
Chaikaβ€’3mo ago
Yea, GTM does need a tracking id
NoFi
NoFiβ€’3mo 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β€’3mo 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
NoFiβ€’3mo ago
I'd stick to CF then So to get rid of google's what do I do? disable it in sellix?
NoFi
NoFiβ€’3mo ago
No description
Chaika
Chaikaβ€’3mo ago
Yea disable it there
NoFi
NoFiβ€’3mo ago
done can you see if it got disabled in the speed thing?
Chaika
Chaikaβ€’3mo 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
NoFiβ€’3mo ago
Yes, everything but rocket loader
Chaika
Chaikaβ€’3mo ago
yea GTM is gone. Your score went from 36 on mobile -> 46, 91 -> 94 on desktop. That's something
NoFi
NoFiβ€’3mo ago
That's pretty good
Chaika
Chaikaβ€’3mo 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
NoFiβ€’3mo ago
Can I limit agro to like $10 a month, so no matter what happens I don't pay more?
Chaika
Chaikaβ€’3mo ago
Sadly no, you can add billing alerts though.
NoFi
NoFiβ€’3mo ago
I don't want to wake up one day with a $1000 bill
Chaika
Chaikaβ€’3mo 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
NoFiβ€’3mo 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β€’3mo 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
NoFiβ€’3mo ago
Oh, these are mine
Chaika
Chaikaβ€’3mo 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
NoFiβ€’3mo ago
Probably yes I'll take care of the images first
NoFi
NoFiβ€’3mo ago
I can only upload these file formats
No description
NoFi
NoFiβ€’3mo ago
Which one should I use?
Chaika
Chaikaβ€’3mo ago
jpeg is compressable and generally smaller. png is loseless/preserves image quality
NoFi
NoFiβ€’3mo ago
Which one should I go for the logo?
Chaika
Chaikaβ€’3mo 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
NoFiβ€’3mo ago
So Like 64x64 would be good? or 128x?
Chaika
Chaikaβ€’3mo ago
Sure, either of those are reasonable. You are forcing the size to 30 height max always, won't get much bigger
NoFi
NoFiβ€’3mo ago
on a 4k screen it would be 4x that, right?
Chaika
Chaikaβ€’3mo ago
nah, you're forcing it to a max of 30 pixels heigh everywhere
NoFi
NoFiβ€’3mo ago
Oh So 30x is okay? It looks much worse now
NoFi
NoFiβ€’3mo ago
No description
NoFi
NoFiβ€’3mo ago
What's wrong? I made it 30x30 I just made it 90x90, looks better well, still bad I don't get it
NoFi
NoFiβ€’3mo ago
No description
Chaika
Chaikaβ€’3mo 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
NoFiβ€’3mo 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
More Posts