0

We have complaints that are related to caching. A Global redirect URL points to a PDF file on the server. People claim they get an old version even after an FTP update.

Using Apache 2.4 D7 and Global Redirect module. URL is in a block (example.com/newsletter) which redirects to sites/files/upload/newsletter.pdf

I don't even know if this is client side or server side caching, but I want to make sure that caching expires daily.

Possible approaches:

  • Use drupal file system to manage this as a field

  • change the redirect type (gloabal redirect supports a few: like 301, 304,307,etc)

  • Add something to the a href tag ?

1 Answer 1

1

I'm guessing you mean the Redirect module, not the Global Redirect module.

One thing to clarify: Are you trying to change the actual destination of the redirect (by initially having example.com/newsletter redirect to sites/files/upload/newsletter.pdf one day, then the next day having it redirect to sites/files/upload/newsletter-2.pdf)? Or (as I think you're saying) are you actually overwriting newsletter.pdf on the server so that it's a different file?

I'll assume you're doing the latter. If so, then the type of redirect doesn't matter. You're facing caching on the browser side and you need to change your mod_expires settings. Assuming you're allowing htaccess files to influence your apache configuration, you can put the following in the mod_expires section of your .htaccess file in the root of your site:

ExpiresByType application/pdf A86400

That would make browsers cache PDF files for a day (86,400 seconds). An alternative, equivalent syntax is:

ExpiresByType application/pdf "access plus 1 day"

You can adjust that parameter however you like. See documentation here.

1
  • I am using the Global Redirect module - but you seem to say it is moot. Yes. it is the latter. Yes I have mod_expires. This looks perfect, although i tried to see the header and it shows no-cache and expiration in the past .... anyway - this looks like it will do the trick!!!! Aug 6, 2015 at 20:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.