Cloudflare and caching images?

How do yo make cloudflare cache *@@images/image/large ?

I try to create page rules for 2 days still no luck, hope get some help about this.

Is that can use rewite in nignx to remove @@images/image/large ?? any idea?

I use CloudFlare with Plone but have not found the need to do any special handling of images. Are you seeing hits on your Plone site for those even with CF in front? What is the problem you are trying to solve?

@tkimnguyen

I wan to cache the jpg images end with @@images/image/large

What makes you think they're not cached?

@tkimnguyen

They show cf-cache-status DYNAMIC but not HIT

And cloudflare people say cloudflare just cache url end with .jpg

So if i can rewrite the

domain.com/photo/xxxx-xxxx.jpg/@@images/image/large

to

domain.com/photo/xxxx-xxxx.jpg

May fix the issue

Have you activated Plone's own caching and made sure you have a rule for "Content files and images"? If so, have you checked to make sure that you're not accidentally stripping the cache response headers somewhere in your delivery stack?

Create a page rule in cloud cache everything work. remember pure all cache.

I sure it don't work yesterday, but it work now.

Glad you figured it out. Can you share what that page rule consists of?

Cloudflare page rules really shouldn't be required if plone.app.caching is turned on and rules are tuned up to match the level of caching you want. Clouflare generally respects Plone's cache headers. (The particular exception is that CF will not cache for a shorter period than allowed by your CF plan, even if Plone's cache headers call for it.)

Maybe you are trying to solving the wrong problem.

I wouldn't expect to see much @@images/image references in the html outputtted by Plone for caching on cloudflare. Most references to images should get their scale rewritten to a semi-permanent unique url like this:

path/to/testimage.png/@@images/c767fd18-b8c6-49bd-b0c8-62e2eb731d31.png

And these url's have the right extension as well.

1 Like

My images is already resized to 800px but the PTG use @@ preview and large to show the photos thats why I have issue with cloudflare.

For rewrite with nginx
I have try Substitutions module (it work) for nginx since at first cloudflare ppl answer the resource need to be cached must be with a .jpg .gif .png etc.

add
subs_filter ^(.*.jpg)/@@images/image/large $1 ir;
inside location /
will work

Now I use the page rule solution (other file with regular extension will be auto cached, I just cache all the photo show by the PTG)

domain.com/photos/*

Browser Integrity Check (on)
Browser Cache TTL (a year)
Cache Level (Cache Everything)
Edge Cache TTL (a month or less)

Remember clear all cache after set this rule

Without
Cache Level (Cache Everything)
cloudflare will just cache files with popular extension only.

Which PTG output plugin are you using, assuming PTG is plonetruegallery?

Unite gallery

Just now all /@@/ media become cf-cache-status: DYNAMIC again... I mean no one change anything...

I have turn off Cloudflare and just plone with varnish now... and discover something very interest.
how come the @@ images with a expire date 2010 ????

date
Tue, 21 Apr 2020 14:30:18 GMT
expires
Sat, 24 Apr 2010 12:33:29 GMT

Final result

If want cloudflare to cache plone image files, beside page rule set to cache all... need to rename those @@ to a regular .jpeg I do use subs filter in nignx for this and confirm it can got cached ... but cloud flare actually slow down my web in my case. Hope my research useful for some new comers.

Probably a way to say "do not expire"