When pdf price lists change old version being displayed

I have a website with 8 price lists and they are linked from 3 different places.

Currently when I upload the price lists I keep the name the same. This time I noticed in IE that in one case the old price list was still displayed and even when the price list was removed it still displayed the old one! Clearing the browser history fixed it but when users visit the site they may still see the old version.

I see my options as:

Rename the files every time which means changing 24 links - a pain.

Put the file names in a database - only need to change 8 items not 24 - less of a pain.

Read the directory containing the price lists and some how change the links to the new version - prefered method but I am not sure how to impliment. Possibly use explode or a regex?

Are you using a CMS to display these links?

I’m not sure if it helps ease the burden of updating the links, but you can tack on a versioning query to the URL, like this:

http://example.org/file/myfile.pdf?20130508

So when you upload the new file, you just change the query portion of the URL.

[edit]: Another possible solution is to replace all the links with a short URL, and have the short URL link to the new file each time.

So, when you have a new file to upload, you just update the source link in your short URL service, but the short URL that is posted everywhere won’t change.

No I am not using as CMS as such but am using a navigation include on every page.

@Force_Flow ; Your comments have made me think that if I add some variables to the navigation file with the pdf file names; all I will need to do is update those every time. I can then echo the variables where I have the links. The new filenames of the price lists will just have the date on the end as you suggested.

[font=verdana]Sounds like you would be better off setting a cache control on the server, to tell user-agents to fetch a new version. I’ve not tried this myself, but this code in your .htaccess should set an expiry date of 24 hours on all PDF files, after which time they should not be cached.

<filesMatch ".(pdf)$">
Header set Cache-Control "max-age=86400, public"
</FilesMatch>

[/font]

That sounds better @Stevie_D ; as it would need no more input from me.

I will give it a go tonight and if it does not work I will try reading the folder of images into an array; finding a file with a name that for instance starts with Toy and putting that into a variable which I can use in my link.

I have just been working on creating dynamic variables and have remembered why I wanted the names to stay the same. If the user bookmarks the pdf and wants to come back to it at a later date and the name has changed they will get an error. The .htaccess method would be the best way to go if it works.

If you use a query variable after the (same) filename, bookmarks don’t break.

[edit]: But…they would load the cached document, so nevermind.

If you use the htaccess method for a specific file/folder, that might be the best approach.

The .htaccess code seems to have worked but can not be sure until I recive some more price lists tomorrow.