-
Notifications
You must be signed in to change notification settings - Fork 198
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
invocation specific rustdoc static files are cached too long on /latest/
#1593
Comments
It seems like there should be a separate suffix for Another possibility would be to make a prefix for invocation-specific items. That prefix could point to the explicitly versioned path ( |
That would have to be a dynamic prefix, the |
Also one additional thing I remembered: when we go the invalidation-way, we have to forbid caching in the browser for these. Does @GuillaumeGomez has an opinion on this? This feels more like a design-question for rustdoc. Should there be an additional suffix for invocation-specific files? Do |
we could also go another way: |
I don't really have an opinion on this. You have needs and if we can match your needs on rustdoc side without making breaking changes, I think it's fine to do it (depending on the size of the change too). |
If we land rust-lang/rust#101702, the toolchain specific files won't get the resource suffix anymore (which is great, better cacheability!). That means docs.rs is free to add crate-specific info to the Edit: Also I should mention I just filed #1851 which proposes a different, more heavyweight intervention: adding an additional flag. What I'm proposing in this comment would be a very lightweight fix (I think); In #1851 I contemplate a more comprehensive but more complicated fix. |
…illaumeGomez rustdoc: add hash to filename of toolchain files All static files used by rustdoc are now stored in static.files/ and their filenames include a hash of their contents. Their filenames no longer include the contents of the --resource-suffix flag. This clarifies caching semantics. Anything in static.files can use Cache-Control: immutable because any updates will show up as a new URL. Invocation-specific files like crates-NN.js, search-index-NN.js, and sidebar-items-NN.js still get the resource suffix. This has a useful side effect: once toolchain files aren't affected by resource suffix, it will become possible for docs.rs to include crate version in the resource suffix. That should fix a caching issue with `/latest/` URLs: rust-lang/docs.rs#1593. My goal is that it should be safe to serve all rustdoc JS, CSS, and fonts with infinite caching headers, even when new versions of a crate are uploaded in the same place as old versions. The --disable-minification flag is removed because it would vary the output of static files based on invocation flags. Instead, for rustdoc development purposes it's preferable to symlink static files to a non-minified copy for quick iteration. Example listing: ``` $ cd build/x86_64-unknown-linux-gnu/doc/ && find . | egrep 'js$|css$' | egrep -v 'sidebar-items|implementors' | sort ./crates1.65.0.js ./rust.css ./search-index1.65.0.js ./source-files1.65.0.js ./static.files/ayu-2bfd0af01c176fd5.css ./static.files/dark-95d11b5416841799.css ./static.files/light-c83a97e93a11f15a.css ./static.files/main-efc63f77fb116394.js ./static.files/normalize-76eba96aa4d2e634.css ./static.files/noscript-5bf457055038775c.css ./static.files/rustdoc-7a422337900fa894.css ./static.files/scrape-examples-3dd10048bcead3a4.js ./static.files/search-47f3c289722672cf.js ./static.files/settings-17b08337296ac774.js ./static.files/settings-3f95eacb845293c0.css ./static.files/source-script-215e9db86679192e.js ./static.files/storage-26d846fcae82ff09.js ``` Fixes rust-lang#98413
…illaumeGomez rustdoc: add hash to filename of toolchain files All static files used by rustdoc are now stored in static.files/ and their filenames include a hash of their contents. Their filenames no longer include the contents of the --resource-suffix flag. This clarifies caching semantics. Anything in static.files can use Cache-Control: immutable because any updates will show up as a new URL. Invocation-specific files like crates-NN.js, search-index-NN.js, and sidebar-items-NN.js still get the resource suffix. This has a useful side effect: once toolchain files aren't affected by resource suffix, it will become possible for docs.rs to include crate version in the resource suffix. That should fix a caching issue with `/latest/` URLs: rust-lang/docs.rs#1593. My goal is that it should be safe to serve all rustdoc JS, CSS, and fonts with infinite caching headers, even when new versions of a crate are uploaded in the same place as old versions. The --disable-minification flag is removed because it would vary the output of static files based on invocation flags. Instead, for rustdoc development purposes it's preferable to symlink static files to a non-minified copy for quick iteration. Example listing: ``` $ cd build/x86_64-unknown-linux-gnu/doc/ && find . | egrep 'js$|css$' | egrep -v 'sidebar-items|implementors' | sort ./crates1.65.0.js ./rust.css ./search-index1.65.0.js ./source-files1.65.0.js ./static.files/ayu-2bfd0af01c176fd5.css ./static.files/dark-95d11b5416841799.css ./static.files/light-c83a97e93a11f15a.css ./static.files/main-efc63f77fb116394.js ./static.files/normalize-76eba96aa4d2e634.css ./static.files/noscript-5bf457055038775c.css ./static.files/rustdoc-7a422337900fa894.css ./static.files/scrape-examples-3dd10048bcead3a4.js ./static.files/search-47f3c289722672cf.js ./static.files/settings-17b08337296ac774.js ./static.files/settings-3f95eacb845293c0.css ./static.files/source-script-215e9db86679192e.js ./static.files/storage-26d846fcae82ff09.js ``` Fixes rust-lang#98413
I want to clarify / wrap up a caching issue I'm seeing. We discovered it in the discussion in #1590 (partially fixed by rust-lang/rust#92742).
For rustdoc we serve three kinds of static file types:
unversioned-shared-resources
like fonts. Will be served fromstatic-root-path
with its filename, not hashed. Cached forever, can never change.toolchain-shared-resources
are static files that might only change when the toolchain (nightly) changes. Will be served fromstatic-root-path
but includes the toolchain version in the filename (via--resource-suffix
). Will be cached forever, when these change, the file name and its references in the HTML changes.Now we come to
invocation-specific
, for examplesitebar-items.js
andsearch-index.js
:Now with
/latest/
the URL for theseinvocation-specific
items don't contain the version any more.so, if there are two releases of a crate with the same nightly version, the cache will still serve the invocation-specific files for both releases
possible solutions?
Another approach could actually be doing the first step towards #1552 by creating an invalidation-request for
/crate_name/*
after each release.I'm open for other ideas.
The text was updated successfully, but these errors were encountered: