Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Genc Kastrati 86 posts 401 karma points
    Jan 11, 2021 @ 09:45
    Genc Kastrati
    0

    Browser caching PDFs

    Hi everyone,

    Probably some of you have noticed that Chrome has this habit of caching media assets in a rather aggressive way, showing an older version even when a file is updated.

    Does anyone have a solution to forcing the browser to detect or at least not cache the Media assets on Umbraco?

    Note: we were using the trick of adding a parameter with ? and a time stamp but since moving to Azure blob this does not work, files get "zipped" by Azure blob. Weird huh.

    Thank you! Genc

  • Genc Kastrati 86 posts 401 karma points
    Feb 15, 2021 @ 20:17
    Genc Kastrati
    100

    Follow up to this post from January, there is a fix using a modified web.config in the Media folder. Simply add portion inside and including httpProtocol:

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <system.webServer>
        <handlers>
          <clear />
          <add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />
        </handlers>
        <httpProtocol>
          <customHeaders>
            <add name="Cache-Control" value="no-cache" />
          </customHeaders>
        </httpProtocol>
      </system.webServer>
    </configuration>
    

    Now Chrome will not cache the PDFs. Seems to work. Thx!

  • Yakov Lebski 591 posts 2347 karma points
    Feb 16, 2021 @ 20:47
    Yakov Lebski
    0

    the simple way is to change URL or query string, it doen't make sence disable cache for client

  • Genc Kastrati 86 posts 401 karma points
    Feb 16, 2021 @ 20:50
    Genc Kastrati
    0

    Problem is using query string on Azure Blob storage with Umbrao Cloud is generating a zip file.

    Here try it yourself, this should be an xlsx file: link

    We can't change all the URLs, some we need to keep consistent. So URL change is not an option either.

    What is the problem with not caching Media items like PDFs or XLSs? We specifically want to be sure the user always gets the latest version.

  • sachin 2 posts 72 karma points
    Dec 15, 2022 @ 13:32
    sachin
    0

    Any solution for this?

Please Sign in or register to post replies

Write your reply to:

Draft