-
Notifications
You must be signed in to change notification settings - Fork 201
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
Add hash to file names after building #2166
Comments
How is the current build system designed when it comes to caching? After building and deploying a new version, how does the user get the new version, while the old ones are cached, and the file names are the same? The documentation about this is non existent. |
We are currently working on a project to make build more customizable. I believe this functionality will be added through that interface once it is built. pinging @justinfagnani to make sure he's aware of this. |
+1 |
Yes, how is this not critical? Not everyone here is ready to uses service workers. Adding a hash at the end of the file name shouldn't be that complicated... |
@eeid26 @jimbojetlag We're currently juggling a lot of critical projects atm :) While there hasn't been any progress on this issue exactly, we have just completed a major refactoring of the build pipeline and pulled it into its own library that anyone can customize and use: https://github.com/Polymer/polymer-build If you're interested in this feature, I'd recommend experimenting with adding https://github.com/sindresorhus/gulp-rev to the polymer-cli build pipeline or to a custom polymer-build pipeline if you already have one (see https://github.com/PolymerElements/generator-polymer-init-custom-build for an example project that has one). And when you get it working, please share what you did here or in a PR! A working demo would be a great first step to getting this prioritized and merged into the CLI. |
I should have a working build/app and a deployed demo app next week |
I created a sample app to use the service worker or browser cache in The sample app uses the request params in the url to update the cache instead of changing the file names. I guess I just followed the way dojo did it before without checking that is not the best way now. Maybe I will add support for busting the cache with request params or with changing the file name. |
The version that uses the file fingerprint in the url is here https://github.com/eeid26/polymer-app2 |
Thanks @eeid26 I will look to see if this works for me. But... 👍 on making this easier and maybe a standard feature of polymer-cli. I don't see how you can launch a production app without managing this. I use versionAppend in an older app that was based on PSK and I'm in the process of moving it to polymer-cli and missing this feature is a blocker... |
I am sure eventually this will be supported by polymer build process. We just need to experiment with what would work first. |
@eeid26 thanks for taking a crack at this! I'll try to take a look at this asap. One thing that makes this much more difficult in an HTML Imports world is that we're referencing the files by path directly (bleeding edge ftw!). Where other build processes build these references for you and can add hashes inside that mapping step, we would need to modify your actual import paths during build. |
Working with AWS S3 and Cloud Front makes it hard without this because CF ignore S3 until unvalidations are performed. I came up with this setup, let me know what you think:
It seems to be working. Otherwise I can only think of a build process in which I should change all files version names. HTML imports should be changed as well as maybe dynamic imports in js (which I have for lazy load for instance). It looks difficult What do you think? |
Is there an update on this? |
Arriving from various other SPA framework, build tools, and CLIs, I found the following two things jointly surprising:
Given how impressive the first bit is (wow!), I'm guessing there is some straightforward temporary workaround for the second bit, maybe someone in the know could write a few words here or elsewhere? Could it be as simple as post-processing the build output with gulp-rev and friends - is the build/ output "safe" to send through such tools? |
While support for this is not yet baked-in, has anyone found a clean way to modify the out-of-the-box build to add this? (New to |
We use custom build with There used to be a bug with |
Thanks! Can you share a few lines of a gulpfile (or npm script etc.) that
can be run on an out-of-the-box Polymer starter kit app to demonstrate?
…On Sat, Sep 2, 2017 at 12:38 PM Sergey Kulikov ***@***.***> wrote:
We use custom build with gulp and polyner-build and the last step is
assets fingerprinting via gulp-rev-all + gulp-rev-replace.
There used to be a bug with gulp-rev-all: it could corrupt occurences
like dom-module id and is, our workaround was to onky use this lib to
generate manifest and another one to rewrite references.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://github.com/Polymer/polymer-cli/issues/283#issuecomment-326755162>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAD94KN7OSnjsYiVKtfBsZSwWYopBLMMks5seYSJgaJpZM4I5Gkj>
.
|
I have to use app cache to support mobile safari (no service worker, yet), so this is crucial and it is delaying things that I have to find a solution, potentially dropping polymer-cli, which is something I don't want to do :/ |
@davidmaxwaterman if you are only using app cache for safari you might want to take a look at https://jakearchibald.com/2016/caching-best-practices/ :) |
@BorntraegerMarc thanks! more reading :) That's a bit more recent than his 'douch bag' one, so that's an improvement. So far, I think I'm using pattern 1 - the files are essentially static, and I only want to change them when I update the app, so the gulp-rev tool is the one I need using the md5sum. I really wanted it to be as simple as polymer-cli makes other such tasks that aren't actually the app....then I found this. |
I think the hashed filename approach works great when the extent of the references tended to be small e.g. To make my app CDN cache friendly I went with using an app-level hash - i.e. I add a hash as a top-level folder so files can be set to cache for a year but loaded as a complete and consistent set by changing this hash when a new version is deployed. This seems to give much better performance for first hit at the expense of possibly having slightly more files re-download when the app is updated (but some of that could be reduced with ETag headers based on the content hash) |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
The best practice for managing cache is to change the file name when it is being updated.
This way, one can set the cache to never expire because the file is immutable.
It would be great to see it implemented in polymer-cli.
Take a look at gulp-rev as an example.
The text was updated successfully, but these errors were encountered: