How to force user to refresh cache

22,044

Solution 1

You can't force user's browser to clear cache from your website. Just change your pdf name and update it's link in your html accordingly when you replace it. This will prevent browsers from loading it from cache.

For instance, if you have a file named form1.pdf and want to replace it with updated version, delete form1.pdf (don't simply replace), name your new file a different name like form1a.pdf & update existing link to point to form1a.pdf.

Solution 2

Please check if you have caching for your static files on the server (is there some kind of CDN like Cloudfront is used? If yes then it could be checking for updates files once in a given period only).

You may also may control caching on the server-side by sending the Cache-Control header to no-cache, must-revalidate (see this for more options)

Share:
22,044

Related videos on Youtube

Ken Jenningson
Author by

Ken Jenningson

Updated on February 10, 2020

Comments

  • Ken Jenningson
    Ken Jenningson over 4 years

    So I'm trying to update my site's pdf forms, but when I changed them in my server, my users only see the old forms.

    Is there a way to automatically force them to refresh the cache so they will see the new files?

  • Ken Jenningson
    Ken Jenningson over 8 years
    I see, would I have to change it to a unique every time I update the file? Or can I switch back and forth between two file names?
  • Arun Sharma
    Arun Sharma over 8 years
    It's better to change it every time as browser can pull it from cache if you use an old name.