Problem
You have probably run into this problem many times. Your client gives you a new file to replace the old one. You say OK, and post the new file and let your client know. They say it’s not changed and you swear it has, you check and it has so you let them know to try again and they and you are suprised that now it works even though you haven’t made a change. You realize the browser has cached the old version but you just suck it up and go on with your life till it happens again. This is very common with large assets like PDF files, Flash files and large images. Also it happens a lot in web applications that replace images.
Solution
Put a query string on the file name. By convention I will have a filename like specifications.pdf and I will just put specificaitons.pdf?v=2 at the end of the href. It doesn’t affect the filename when downloaded but does tell the browser that it is a new file. It’s much nicer than putting these version or dates into the actual filename unless that is required of you, which keeps the filename nice and simple.
For web applications that change files and display them like an image cropper for example, a great way is to append a datetime on the end of the newly uploaded file. So that would be filename.jpg?2010-11-30-11:10:23 or what ever format you prefer. This can be accomplished server or client side, so what ever option you prefer.
