-
Notifications
You must be signed in to change notification settings - Fork 806
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
How to config use file hashing instead of query strings ? #934
Comments
Agreed. It seemed to work this way in a previous version but I just upgraded and, to my dismay, we now have query strings for cache busting. I was under the impression that query strings had potential issues as a cache busting method. See other discussions of cache busting techniques and why query strings should be avoided: https://www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/ Unless there's some new knowledge that I'm not privy to, I would strongly vote in favor of returning to the static file name with content hash as the default. |
I did a good bit of research and found that query string based caching should be more than adequate. Much of the research, as you linked to, is from pre-2010 and doesn't 100% apply anymore. For example, Squid has no issues anymore. If you use something like Cloudflare's CDN, you only have to click a button to activate query string busting. There is no way in Mix 1.0 to use file-based hashing unless you want to implement it yourself within |
Fair enough. I understand that the library version is now stabilized and unlikely to make a change like that. Do you have any resources that you can point to that support your findings? I'd like to make sure I'm up-to-date as well, because two of the three articles I linked were actually from 2015 or later. |
The second link provided actually recommends query strings. It also links to a maxcdn site that recommends them. Here's Jeffrey's tweet asking for feedback: |
The second link doesn't "recommend" anything. It's merely a comparison of different strategies and asking for feedback. It says that most CDNs support and recommend them, but even the example linked to from that article doesn't actually recommend anything. It simply explains how to use query strings for cache busting and how to configure the CDN to support it. I think the main trouble, in general, is that the majority of opinions on the subject are just that. There isn't much hard evidence to support a best practice without having a comprehensive review of the impact across various browsers, servers, CDNs, etc. Asking for opinions on Twitter is hardly scientific. I was hoping for some supporting hard evidence that would disprove my possibly outdated opinion on the matter. |
Quoting the article
The last sentence then links to maxcdn's recommended approach. However you interpret that, any modern cdn supports it. A non-issue. |
Also, I'm sure the Twitter question was merely a small piece of the investigation done before making a change that affects thousands of websites. I'm sure if any real issues actually ever arise, appropriate action will be taken. To now, the only evidence is second-hand info. |
So, my opinion is: Let the users to choice which one to use with a configuration. Some users maybe not use any Modern-CDN, or maybe even just use their servers instead for some reasons and no switching ability. The reality is more complex. Hope for adding a way to fallback if it's not hard to U, as acting like pre-version Mix. So that we can update to the latest Laravel happily. Thanks |
You are right about it because a lot page optimizers (including Google's) complain about using query string in static assets. I hope they add it back too. |
I don't really think this is a "non-issue". There are cases where you need both versions of the code, mainly during a deployment to multiple servers. We are doing one-at-a-time deployments to about 10 servers. We send our assets to S3/Cloudfront before deploying any backend code. In most cases, this probably isn't an issue. There are a couple different types of users that can hit the site during a deployment:
User 1 should have no issues, the old version will very likely be in their browser cache, so they can continue to use the site on whatever code is on the back end server they happen to be hitting. User 2, however, is only fine if the old cached version exists in the Cloudfront edge they are hitting. If it does not, they have new assets with old backend code, which is potentially a messed up site. Granted, this should only be for a few minutes max, but it's not exactly the ideal situation I want to show new users. That is with a CDN in front. Remove that, and the problems become much worse. User 2 could end up caching old assets with the new hash. Perhaps our deployment strategy is garbage. I know there are other options here, but not without either losing server power or adding it during a deployment (neither of which I think are ideal, but options nonetheless). Hashed file names just work in so many more different situations. |
Really disappointed in this solution as query string cache busting doesn't work 100% of the time for our users. Shouldn't have to tell a client to shift refresh to see changes. Changing the file name works, query strings do not. Should at least be an option. |
Any update on this? is this feature/option likely to make it into Mix? |
If someone tells that "query string is enough" then I have one question - what about rolling updates?? If versioning was using hashing not query string I could do it like that: |
If you're using a CDN that handles long-term asset caching based on query string then the old version will be in the cache even after you upload the new file. This will handle rolling updates appropriately. Having said that there are other reasons that using file name versioning could be a good idea like the ability to use an immutable cache and protection from file/image/etc… name collisions during the build process. re: asset collisions — file-named versioning is the only real solution to this problem as such I think it'd be reasonable to at least add an option to enable it for everything if we're going to enable it there. However, most use cases do not need it and I see no reason to change the default if we do make this configurable. I'm going to re-open this and possibly make it an option in Mix v6.1 |
How is this coming along? We've started seeing some users running Edge where the browser is ignoring the querystring cache busting entirely and keeping the old copy cached instead. As someone mentioned above, it's embarassing having to tell clients to force-refresh to fix these issues. |
We - old people - use query strings to input data into a web application. I use a webserver rule that strips out version from URL path: |
I prefer use file hashing, when I publish assets files to CDN.
Specifically, I publish assets files to CDN first, and then publish php code to my servers one by one.
So some server may be using old version assets file of CDN.
Is there a way to config use file hashing?
The text was updated successfully, but these errors were encountered: