HTML target cacheBreak


#1

Hi,
i was setting up a CDN, with lots of cache settings for bigger files etc. But it did not work for my haxe project, which made me crazy. Then i realized, that the cache was bypassed with “__cacheBreak” in AssetLibrary.hx. Is there any clean way to disable it?


#2

I believe you can set Assets.cache.version yourself, and that will affect the string appended to the end when requesting assets.

There isn’t currently a define to disable the behavior, though. I wouldn’t be against it


#3

Thanks, that helps.I have set version to 0, but i’m still not happy about the extra parameter, so i do the cachebreak only if Assets.cache.version is not 0. Maybe this could be done with Assets.cache.version as a Null<Int> to be super clean? :slight_smile:


#4

I’d be okay with handling the parameter only if greater than zero. We could assume that cache breaking applies to non-zero versions (and that no parameter “is” the zero version)


#5

Hi again,

i tried Assets.cache.version = 0;, but cache will still be broken. Is this wrong or do i have to play it somewhere special?

Our game is just arround 50mb, but even from a google cdn it can take horrible long for players with a bad connection to start it.


#6

You would need to set the cache.version before the preloader starts, otherwise it will already pull in cache-broken resource paths to load. You could do this by using a custom ApplicationMain.hx template, though I’m open to adding -lime-disable-assets-cache-break or something like that (maybe a shorter define?) or perhaps the goal is to add an exception for a specific file extension?

It’s important to have the cache break for SWF assets, particularly, which re-use file names on export that will not match previous exports if the SWF contents changed


#7

Sounds great to me. Maybe a bit long, but it describes what it does :wink:


#8

I think this should help:

I added a few things here:

  • -Dlime-assets-version=100 to set an asset cache version manually
  • -Dlime-disable-assets-version to disable asset caching
  • Assets.cache.version = 0 to manually disable caching at runtime (but this won’t affect preloading, only Assets.load__ methods)

#9

Thank you a lot!

Keep up the great work!


#10

This has been released in OpenFL 8.8.0!