-
-
Notifications
You must be signed in to change notification settings - Fork 70
dependent files rev names and cache #85
Comments
You should have the names updated as part of your build process, not manually managing things like this. |
It is done automatically by grunt-usemin. |
In that case the file names should be updated whenever you run |
Yes, everything is working but the scenario that I described is problematic. The file name is updated based on hash function the depends on the content. |
Oh ok. Hmm. This is really tricky to solve and I'm not even sure if its a filerev or usemin problem. |
Yes, but I am sure I am not the only one who encountered this issue. I saw this on production in few of my projects and it took me quit some time to understand what is wrong. The usemin is only updating the the links, it is not in charge of the file names. Maybe adding a random algorithm to the hash function options? With random naming, each build we will have new names for all files, this is will impact caching of course but in the current solution you site can be broken on production. What do you say? |
After thinking about this, without doing a ton of crazy voodoo magic and a lot of work, the simplest solution would be to change something in a.html as well. A better solution would be to double rev/update the files. But again, lots more work. |
Yes, I agree that changing a file is a good solution but this need to be automated. Otherwise there is no chance anyone will remember to do this everytime |
I have the same problem, you're not alone ;). I'm using :
If I modify an image from the sprite, the new generated sprite get a new revved filename but style.css doesn't update its revved filename.. so the browser cache never gets updated. I think the problem is that all the rev-logic is performed in one go (filerev->usemin).. i'll try to separate this process :
|
It works ;) Grunt taks (after concat/uglify, etc) : It feels more like a workaround .. don't know if filerev/usemin should be corrected to handle that automatically ... but hope I helped. |
@Bixibu Can you please write your entire Gruntfile please? I am overcoming this issue currentlt with grunt-angular-templates task, as it is creating the html templates inside the angular template cache |
My Gruntfile is made of 1500+ lines :/ So basically,
filerev: {
options: {
encoding: 'utf8',
algorithm: 'md5',
length: 8
},
// top files
source: {
files: [{
src: [
'<%= dest.js %>/**/*.js',
'<%= dest.css %>/**/*.css'
]
}]
},
// inner dependencies of top files
assets: {
files: [{
src: [
'<%= dest.assets %>/**/*.{jpg,jpeg,gif,png,ico}'
]
}]
}
},
usemin: {
html: ['<%= dest.html.all %>'],
css: ['<%= dest.css %>/**/*.css'],
js: ['<%= dest.js %>/**/*.js', '<%= dest.html.all %>'],
options: {
dirs: ['<%= dest.root %>'],
assetsDirs: ['<%= dest.root %>'],
patterns: {
js: [
[/["']([^:"']+\.(?:png|gif|jpe?g))["']/img, 'Image replacement in js files'],
[/["']([^:"']+\.css)["']/img, 'CSS replacement in js files']
]
}
}
}, I have no problem with angular templates, but I use html2js to merge all my html tempaltes in a single js file (which get revved without problem) |
Lets say I have 2 html files:
a.html
b.html
a.html is pointing to b.html in his markup (ng-inlcude for example). Now, i have made changes in file b.html but not in a.html -> a.html will have the same revved file name, but b.html will have a different name -> if a.html that points to the old revved name of b.html is cached in the client he will get a broken link.
How I can solve this issue? Am i doing something wrong?
The text was updated successfully, but these errors were encountered: