问题
I have a feeling I should know this.
I have a web app that contains a large number of images, css and script files.
The problem I'm having is that if I update the app and one of these 'static' items has changed, I need to ensure that a browser accessing the app is using the newest version of the file.
I know I can't clear the client cache from my app so that's out.
I'm sure that I'm not the only guy to have had this issue so I thought I'd ask here. I've found lots of stuff about the server cache but nothing that obviously deals with this.
Anyone any pointers I can follow up?
-- Stuart
回答1:
Use a get method at the end to make the browser think it's dynamic content that need to be updated.
For example
<img src="img.jpg?version=1" />
And just change version
id every time you change the image. You might use this in css and javascript imported as well.
来源:https://stackoverflow.com/questions/8443441/how-do-i-force-a-given-file-to-expire-in-the-cache