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

Playground Block: set style version number #256

Merged
merged 1 commit into from
May 8, 2024

Conversation

bgrgicak
Copy link
Collaborator

@bgrgicak bgrgicak commented May 8, 2024

Fixes #254

What?

This PR ensures that the style cache will be busted when a new version is released.

Why?

The style version is currently displayed as 0.0.1 which matches block.json.
When a new version of the plugin is released, browsers keep returning the cached version of the style file which might be outdate.

How?

The style file is now manually registered and a version is set to the last modified time of the file. This will ensure that if a new version is installed, browsers will flush the cache.

Testing Instructions

  1. Check out the branch.
  2. Start a local dev site
  3. Open a post edit page and add a playground block
  4. In network tools confirm that the style path has a timestamp as a version (e.g. build/style-index.css?ver=1715165957)

@bgrgicak bgrgicak added Bug Something isn't working Playground block labels May 8, 2024
@bgrgicak bgrgicak requested a review from adamziel May 8, 2024 11:08
@bgrgicak bgrgicak self-assigned this May 8, 2024
@adamziel adamziel merged commit f1dae3a into trunk May 8, 2024
2 checks passed
@adamziel adamziel deleted the fix/block-asset-cache-busting branch May 8, 2024 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Playground block
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Playground Block: Cache bust CSS and JS
2 participants