Let Cloudflare not cache external files in src of iframe


#1

Hello

I am trying to make a playground like plunker. I just notice a very odd behaviour on production (with active mode in CloudFlare), whereas it works well in localhost.

By iframe, the playground previews index_internal.html which may contain links to other files (eg, .js, .css). iframe is able to interpret external links such as <script src="script.js"></script>.

So each time a user modifies their file (eg, script.js) on the editor, my program saves the new file into a temporary folder in the server, then refresh the iframe by iframe.src = iframe.src, it works well in localhost.

However, I realise that, in production (with active mode in CloudFlare), the browser always keeps loading the initial script.js, even though users modify it in the editor and a new version is written in the folder in the server.

If I turn Cloudflare to development mode, script.js is reloaded successfully.

So apparently CloudFlare caches these JS files in the source of iframe, I tried methods like iframe.contentWindow.location.reload(true), but it did not help.

Does anyone know how to let CloudFlare in active mode not cache these files?

Thanks

Tie


#2

You set up a page rule in CF to not cache that js file. You can use wildcards in case part of the path is unique to the user.


#3

Thank you…

Let’s say I want to NEVER cache files inside www.mysite.com/tmp/*, what setting should I choose?


#4

This article may be helpful.


#5

I have seen this. For the Custom Caching: part, it is not very clear which setting to choose if I want to disable caching for a subfolder.