Does cloudflare cache only images or the webpages themselves?

Hi,

What are the exact steps to make sure that cloudflare only cashing images and not the webpages themselves? (beacause they are dynamic)
Please put into consideration that I am not an expert! :slight_smile:

Cloudflare caches by file extension, and unless you configure it differently HTML is not included in there

2 Likes

You meant that cloudflare doesn’t cashe webpages by default?!
How can I determine the extension that I need it to be cashed?
I just need PNG images to be cashed on my website

You’d specify that via page rules. One to enable caching for PNG files and a second one to disable it for everything else (assuming that is what you want).

Yes! that’s exactly what I really want :slight_smile: sorry for bothering you but if you could tell me what exactly to do (exact steps) in page rules in order to do that I’d be grateful becasue I’m not expert at all! thanks in advance.

Check out https://support.cloudflare.com/hc/en-us/articles/218411427-Understanding-and-Configuring-Cloudflare-Page-Rules-Page-Rules-Tutorial-

Should you have any issues, post screenshots of your page rules here and we go from there. Also, refer to my earlier explanation of how they need to be set up.

1 Like

OK now I added one page rule --> Cashe Level —> bypass – to prevent cloudflare from cashing everything
now what should I do to make clouldflare cashe PNG or images ?

Thats the second rule, you still the need the first one, which actually caches the PNG files. Also, dont specify the protocol, right now it will only apply to HTTP requests but will skip HTTPS.

you meant a seperated page rule right? so I shouldn’t add a setting but adding a new page rule am I right?

Yes, you need to rules. #1 to cache PNG files, #2 to skip everything else (what you already configured). And make sure they are in their right order too (hence #1 and #2).

1 Like

Alright I got it I really do appreciate your help!
my question is what to choose from cashe level to make PNG cashe

  • no query string
  • ignore query string
  • standard ?

or chosing a different setting type at all ?

That depends on whether the query string is important for your caching decision or not. Generally Standard should work, but that really comes down to your specific setup.

1 Like

OK I added standard cashe level but when I’m trying to add another case level (bypass) it shows this " Your zone already has an existing page rule with that URL. If you are modifying only page rule settings use the Edit Page Rule option instead" I think it’s un needed right?

Can you post a screenshot of the rules list?


that’s the only rule I added

Cashe level – standard

I will add another one now for admin dashboard security

do I have to add another setting to the first rule regarding the cashe level – standard?
should I add the browser cashe TTL ? if yes, what is the standard time to be set
?

That is the rule you already posted earlier. What about the second (respectively first) one I kept mentioning?

now I added level cashe level – standard as a first rule page
and added another security one for admin dashboard as this screenshot am I right?

None of that is PNG related though, and with the current order the second rule will never execute and you will always apply the standard caching level.

Again, please follow my original explanation, assuming you dont want to cache anything except for PNG files.