metabase / metabase

The simplest, fastest way to get business intelligence and analytics to everyone in your company :yum:
https://metabase.com
Other
38.72k stars 5.14k forks source link

handle FE asset caching smartly #793

Closed kdoh closed 9 years ago

kdoh commented 9 years ago

Need a way to bust stale caches when assets change.

tlrobinson commented 9 years ago

You mean like https://github.com/metabase/metabase-init/tree/asset_cache_busting ?

kdoh commented 9 years ago

whiskey_salute

agilliland commented 9 years ago

Yeah, that's pretty close to what I originally had in mind. I would actually prefer it if the hash was part of the filename though, it's a little strange to have a ?<hash> appended onto the file.

So I was thinking something more like vendor.<hash>.js and app.<hash>.js

The rest of the approach looks sensible to me. Its not loading the css for me, but everything else looks good.

tlrobinson commented 9 years ago

The advantage of doing ?<hash> is that you don't end up with a zillion extra files, but I guess that's only really an issue for development (which we could add a special case for, like stripping the .mins)

agilliland commented 9 years ago

got it. the main thing that makes me itchy is having urls like /vendor.js?<hash> where the filename of the asset includes the query string. that just feels wrong.

obviously one other alternative could be to just use random hashes in the index.html but don't change anything about the way the bundles are created. that would also bust the cache correct? the main thing being that the url used in the browser is changing regularly.

agilliland commented 9 years ago

in any case. lets just focus on a solution that works for right now so that we can ship it today. we can make the solution more elegant down the road.

tlrobinson commented 9 years ago

@agilliland To clarify, Webpack is smart enough to not actually include the query string in the filename on disk, only in the URL in the HTML, which I think is what I think you mean by "just use random hashes in the index.html but don't change anything about the way the bundles are created".

And yes it will still bust the cache even though the filename on disk doesn't change (the browser doesn't know that)

I was surprised by that since the parameter is called "filename", but I think it's what we want.

tlrobinson commented 9 years ago

794