How to enable cache for extension-less images?

Hello,

I am trying to enable cf cache for images stored in a firebase bucket. These images don’t have any extension although the content type is ‘images/jpg’.
I have created a cname record for the target bucket, so requests are made through a subdomain which is proxied through cf.
If i put an image with .jpg extension in the bucket and visit it, it’s ‘cf-cache-status’ indicates as ‘hit’. but all other extension-less images’ ‘cf-cache-status’ is ‘dynamic’. So as per the ‘cf-cache-status’ header indicates my extension-less images are not being cached in cf.
After reading documentations, i added a page rule with ‘cache everything’ and ‘edge cache ttl=1 month’. but still i don’t see those images getting cached in cf.
Could anyone please explain me how can i enable caching for these extension-less images ?

Thank you.

Cache everything should do exactly as the name suggests, unless you send headers which specifically prohibit caching (e.g. cookies).

Post an example URL.

Here is a link for an extension less image: https://assets.saruwata.lk/live/posts/1619161485908/desktop_1619161485908_0

This is a link for a image with extension: https://assets.saruwata.lk/live/wallpaper.jpg

Page rule:
url: assets.saruwata.lk/*
cache level: cache everything
edge cache ttl: 1 month

And that’s the only page rule? Any Workers in place?

Yes that is the only page rule and there is no any worker.

And you are configuring this in the account with the nameservers Chad and Amalia?

Yes those are the two nameservers.
i have attached a cache performance screenshot filtered by the relevant hostname which is assets.saruwata.lk.

Well, the page rule does not seem to fire at all. It might be best to open a support ticket and clarify this with support.

You seem to be sending a Vary header but I am not sure if that should really make a difference when it comes to caching in this case. Alternatively, would you be comfortable sharing the origin address here?

Your record assets.saruwata.lk is managed by application. This application is a Worker, hence your page rule is not applied because Workers are executed before Page Rules.

If the assets are not cached via this Worker, please reach out to the developer team of this application to get this fixed.

So the OP is running a Worker? He earlier denied that. In that case that will be down to the Worker logic.

I can’t see the Worker in my dashboard as @ncano has replied to my support ticket.

Thank you for both of you for supporting. i have contacted the devs of that App and hope they will help me to solve this issue. I guess their worker’s logic only considers assets with an extension.

Well, Cloudflare applications typically include Workers as well, so this is where the Worker comes in and in this case the Worker will handle the request before the page rule, which is why it does not fire.

Don’t know which application it is, but you could try disabling it for now.

Can I just ask… what is the reason for having no extension?

I searched about it, and all I found were posts on StackExchange and elsewhere from people trying to get it to work properly. I couldn’t find anything about why this setup would be used.

I use Google/Bing/TinEye image search a lot, mainly to keep track of my own images and how they rank, and I can’t remember ever finding an extension-less image that ranked well. I’ve seen them before (they stand out because they save as ‘download.jpg’) but not from image search.

Anyway, I assume you don’t intend to rank these images in search because it’s a Firebase bucket, but I’m still curious… why not just have an extension?

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.