Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache busting support #322

Open
epage opened this issue Nov 2, 2017 · 4 comments
Open

Cache busting support #322

epage opened this issue Nov 2, 2017 · 4 comments
Labels
enhancement Improve the expected question Uncertainty is involved

Comments

@epage
Copy link
Member

epage commented Nov 2, 2017

This is created from #254.

Options

  • site.bust_cache variable that is a timestamp of when the program is run
  • asset.<path>.bust_cache variable that is checksum of the asset
    • This must be conditionally enabled to avoid the performance hit for people who don't care
@epage epage added the enhancement Improve the expected label Nov 4, 2017
@epage epage added the question Uncertainty is involved label Mar 19, 2018
@berkus
Copy link

berkus commented Oct 29, 2018

This sounds right, and supporting both options should be done. Some sites would opt for nothing, some for site timestamp, and some with bigger cache pressure might just want the per-asset cache buster.

Probably a config option, cache-bust: with values none, timestamp(default) and checksum?

@epage
Copy link
Member Author

epage commented Oct 29, 2018

I think both can be implemented with little problem.

The site timestamp is the easiest to get implemented.

An asset checksum might take more work. It can be done now but the performance hit might be a frustration. I can see the idea of having a flag for that. Moe ideally, I think is a refactoring I want to do. The idea is to re-architect inspired by ECS which would effectively make our data an "customized, in-memory database". That combined with some tweaks for Liquid would allow our checksumming to be lazy.

One of the design problems I've been having with asset checksum and general page metadata is how to make it work. If I take "./css/theme.css" and turn it into asset.css.theme.checksum, what if we had a checksum file? How do we make asset / page metadata not conflict with user content?

We might say "just include the extension". So

asset.css.theme.checksum
becomes
asset.css.theme.css.checksum
but what if someone has a theme/css?

Thoughts on a solution

  • We could create a scheme for this to always work.
  • We could make this not always work and just define what the behavior will be
    • This depends on the type of metadata we provide. What is the probability of a conflict?

@berkus
Copy link

berkus commented Oct 31, 2018

could it become something like asset.css.theme$checksum$ ?

@SArpnt
Copy link

SArpnt commented Jul 23, 2022

about the performance hit from an asset checksum, your problem is probably using the wrong hash algorithm. web assets don't need cryptographic hashes. i think the correct hash for this use case would be xxhash16.
whichever hash algorithm that gets used should be documented so that it can be matched with other tools, for example to change urls in javascript to match

also, about the design conflict, i'd expect selecting files to work something like asset.css."theme.css".checksum, and only allow asset.css.theme if there aren't any other files that have the same name but other extension. asset.css.theme.css would never work since theme isn't a folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve the expected question Uncertainty is involved
Projects
None yet
Development

No branches or pull requests

3 participants