• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

Force reload (do not use browser cache) of PDF

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Force reload (do not use browser cache) of PDF

    Hi,
    We have an application that shows pdf's in a URL widget. These pdf's can change but keep the same name. Now it seems that the browser keeps showing the old version until I clear my cache. Is there a way to tell the browser not to use the cached version?
    Kind regards,
    Theo

  • #2
    An option would be that I could add some html to the page presented, like:
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">

    Comment


    • #3
      Hi Theo,

      You could also stop the cache a couple of other ways by adding a cache buster to the URL.

      Example 1 - random number on the data source
      Data Source SQL
      Code:
      select
      cname,
      rand() AS cachebust,
      Then add that to the url via behaviors :
      Code:
      /myPath/index.html?dc_={CACHEBUST}
      Example 2 - if you're using an app var linked to your URL

      Before showing URL widget execute script to add the cache buster:
      Code:
      var url = getAppVar('URL');
      
      // add cache buster
      //
      url += '?dc_=' + Math.random();
      
      // set the app var
      //
      setAppVar('URL', url);
      success();

      Comment


      • #4
        Hi Theo -

        You can add a parameter to the URL when you set it for the widget. For example, suppose the URL is:

        /myPdfs/customers/acme/12345.pdf

        Let's add a parameter named "cb" (short for cachebuster):

        /myPdfs/customers/acme/12345.pdf?cb=20201030091510

        In this case we are using a timestamp as the parameter value.

        Does the path to your PDF come from a data source? If so, maybe just add a new field to your data source:

        current_timestamp as tStamp

        Then use this new field when you set the URL for the URL widget:

        {MYPATH}?cb={TSTAMP}

        Comment


        • #5
          Thanks, that worked and was much easier than I thought!

          Comment

          Working...
          X