WebFile Caching and Custom URL

The Cached property on a WebFile is read only. How do you make the browser cache a file?. I haven’t seen mine being cached and I assume it’s because the path is always different.

Also, is there a way to customise the WebFile url? I want to be able to group a bunch together so they’re easier to find when testing and don’t just have some random number and letters as it’s path making me open each one till I find it

I think the best place to do this is using the WebApplication.HandleURL event. There you will have 100% control of the URL path and response headers.

1 Like

A little bit tricker but that’ll work. Thanks Ricardo!
Is it worth adding a feature request ticket to expand on WebFiles to have that functionality?

I use WebFiles mostly for WebSDKUIControls and I like having the CSS and Javascript data in constants on that control. I can store it in a dictionary ready for the HandleURL request but just adds a lot more steps in

Is it for the URLs you’re returning from SessionCSSURLs and SessionJavascriptURLs? If so, I think a Feature Request is worth it, yes. We are already handling permanent cache (with automatic invalidation) for our framework files, it makes sense to continue expanding on this.

In any case, make sure to set WebFile.Session to Nil, if you want to reuse the same file for all your sessions.

Another feature request that would make sense is to be able to manage the cache headers in WebFile, at the moment it seems to be forcing the browser to avoid caching them no matter what.

1 Like