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

Update name of css and js files (cache busting) #3017

Merged
merged 4 commits into from
Jun 18, 2024

Conversation

colleenmcginnis
Copy link
Contributor

@colleenmcginnis colleenmcginnis commented Jun 18, 2024

Change the name of the CSS and JS files to force users to download a new file instead of using a cached version of the existing CSS and JS files.

⚠️ IMPORTANT: If you are looking at this PR as an example of how to do this again or elsewhere (👋 future me) make sure you also change the code in #3019.

Here's what we learned throughout the process:

  • When we just tried changing the name of the file that is generated (styles.css to styles-v1.css and docs.js to docs-v1.js), both the tests and the build failed, with the following error:
     Parcel didn't make /tmp/parcel/styles-v1.css at lib/ES/Util.pm line 740
    
  • When we looked at line 740 in the lib/ES/Util.pm file, we saw that this was right after running the Parcel CLI. We decided to try renaming not only the name of the file to be created and sent to built-docs as static assets, but also renaming the source files (styles.pcss to styles-v1.pcss and index.js and index-v1.js). After making that change, the build succeeded, but we still had three failing tests related to running the docs locally using --open. All three errors were coming from spec/single_book_spec.rb and were related to the fact that it couldn't find the appropriate CSS/JS files to watch and update automatically when developing locally:
    expected status [200] but was [404]
    
  • Finally, to address this we found one last reference to docs.js that we missed because the . was escaped because it was in a regular expression (docs\\.js). This was fixed in Fixes failing test #3019 where both the build and the tests passed.

Copy link

A documentation preview will be available soon.

Request a new doc build by commenting
  • Rebuild this PR: run docs-build
  • Rebuild this PR and all Elastic docs: run docs-build rebuild

run docs-build is much faster than run docs-build rebuild. A rebuild should only be needed in rare situations.

If your PR continues to fail for an unknown reason, the doc build pipeline may be broken. Elastic employees can check the pipeline status here.

@colleenmcginnis colleenmcginnis marked this pull request as ready for review June 18, 2024 21:47
@colleenmcginnis colleenmcginnis requested a review from a team as a code owner June 18, 2024 21:47
@bmorelli25
Copy link
Member

Failing docs-test is okay.

@bmorelli25 bmorelli25 merged commit 0eae7e0 into elastic:master Jun 18, 2024
2 of 3 checks passed
@colleenmcginnis colleenmcginnis changed the title Update name of css and js files Update name of css and js files (cache-busting) Jun 19, 2024
@colleenmcginnis colleenmcginnis changed the title Update name of css and js files (cache-busting) Update name of css and js files (cache busting) Jun 19, 2024
@colleenmcginnis colleenmcginnis deleted the cache-bust branch June 19, 2024 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants