1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

.htaccess Disable Cache for pdf files

Discussion in 'Apache' started by versus2, Dec 5, 2011.

  1. #1
    Hi,

    I have a problem with pdf files on my site that are being replaced from time to time by pdf files with the same name (updates).

    Users reporting that they still see the old, not updated files, so assuming they have some kind of browser cache, I'm trying to force their browsers loading the new files.

    I have tried the following code on the .htaccess


    RewriteEngine On
    
    # disable caching for dynamic files
    <FilesMatch "\.(txt|pdf)$">
    Header set Cache-Control: "max-age=0, no-store"
    </FilesMatch>
    
    Code (markup):
    It didn't help and some still reporting they see the old files.

    How can I disable any cache for any pdf on the site and force them to load the new files ??

    Thanks.
    SEMrush
     
    versus2, Dec 5, 2011 IP
    SEMrush
  2. adimsh

    adimsh Member

    Messages:
    25
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    48
    #2
    try this
    # disable caching for dynamic files
    <FilesMatch "\.(txt|pdf)$">
      ExpiresActive On
      ExpiresDefault A1
    
      Header set Cache-Control "max-age=0, no-store, must-revalidate"
    </FilesMatch>
    Code (markup):
    If you have mod_expire enabled, this should work without errors, else, remove the first Expire* directives, the "Header ser" directive should be enough, you have to use the header name without ':' after it.
     
    adimsh, Dec 5, 2011 IP
  3. versus2

    versus2 Well-Known Member

    Messages:
    796
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    110
    #3
    Thanks for the help.

    Yes, the code as is caused a 500 server error, so I've removed the Expire* directives..

    However, some people still reporing that they see the old files.. It drives me insane because I don't know what else can I do... Any idea ?
     
    versus2, Dec 6, 2011 IP