SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,431
    Mentioned
    82 Post(s)
    Tagged
    3 Thread(s)

    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?

  2. #2
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,615
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    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.
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  3. #3
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,431
    Mentioned
    82 Post(s)
    Tagged
    3 Thread(s)
    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.

  4. #4
    Mouse catcher silver trophy Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,892
    Mentioned
    123 Post(s)
    Tagged
    1 Thread(s)
    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.
    Code:
    <filesMatch ".(pdf)$">
    Header set Cache-Control "max-age=86400, public"
    </FilesMatch>

  5. #5
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,431
    Mentioned
    82 Post(s)
    Tagged
    3 Thread(s)
    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.

  6. #6
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,431
    Mentioned
    82 Post(s)
    Tagged
    3 Thread(s)
    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.

  7. #7
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,615
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Rubble View Post
    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.
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  8. #8
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,431
    Mentioned
    82 Post(s)
    Tagged
    3 Thread(s)
    The .htaccess code seems to have worked but can not be sure until I recive some more price lists tomorrow.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •