-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
Caching Plugins and ContentHash #1240
Comments
I understand what you are saying, but I do not think having an option to remove In such cases, trying to enqueue older files from older version of manifest can lead to bigger errors. One solution would be to completely remove runtime chunk and split chunks. But that would deny the very purpose of this tooling. We do want to be able to
I hope I am making sense. Let me know what you think. |
Ah, makes complete sense. Very helpful explanation. I didn't know the order could change with Webpack, so definitely a no-go. I really wish caching plugins would invalidate cache on plugin update, but for some reason that's not best practice. Seems there's no good solution here, unless we can get caching plugins to change their behavior. |
What caching plugin are you using? I have used WP Super Cache and it does exactly that. |
WP Rocket is one specific one: https://docs.wp-rocket.me/article/78-how-often-is-the-cache-updated But I've also experienced this with Cloudways/Breeze. I think some standard behavior for some of these is not to clear cache when a plugin is updated. |
Just had a random thought on this (after 6 months 🤣 ). It sounds like content hash could be changed to a query parameter (much like how WordPress versions files): filename: `${this.appDir}/[name].js${!this.isDev && '?v=[contenthash:8]'}`, Interested to know your thoughts on this. If you think it's worth exploring I'm happy to open a PR. |
I think I do have the issue. What would you recommend to fix it? |
Using Webpacks
contenthash
in the filename doesn't work well with most caching plugins. This is because when a plugin is updated, best practice is not to clear site cache. This can cause 404 errors with javascript files, since the filenames can change on each release and the page html is cached with the previous files.I would propose removing the
[chunkhash:8]
from the webpack config and instead rely on plugin version query variables to invalidate the cache.wp-webpack-script/packages/scripts/src/config/WebpackConfigHelper.ts
Line 238 in 73e1702
This will ensure plugin javascript does not break in the case where caching plugins are preset.
As a workaround, perhaps there could be an option to disable the hash portion with an option. Would be curious to know your thoughts.
The text was updated successfully, but these errors were encountered: