NetTalk Central

Author Topic: Avoid downloaded file been served from browser cache (SOLVED)  (Read 3768 times)

Poul Jensen

  • Full Member
  • ***
  • Posts: 247
    • View Profile
    • Email
Hi,

Using this to download a file:
Code: [Select]
p_web.HeaderDetails.ContentDisposition =  'attachment; filename="'& CLIP(Loc:DownloadFileName) &'"'
Works fine first time, but if user later downloads same file, it is being served from internet browsers cache, and therefore not the latest version af the file.

How can I avoid this?

tia
/Poul
« Last Edit: May 17, 2025, 07:20:11 AM by Poul Jensen »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11310
    • View Profile
Re: Avoid downloaded file been served from browser cache
« Reply #1 on: May 13, 2025, 06:44:16 AM »
first you need to determine if it's coming from the local client cache, or the server cache.
(Both the browser, like Chrome or Edge) and the NetTalk server can cache files.

There are headers you can set when serving the file to indicate it's uncacheable. (You can google for that if you like, or look in netweb.clw.)
Alternatively you can alter the URL - by adding a random parameter. For example;

capesoft.com\somefile.saf?r=123
is different from
capesoft.com\somefile.saf?r=321

So simple by adding a parameter (which the server happily ignores) with a random value, the client won't get it from cache.
Obviously though it depends on how they are seeing the URL in the first place to download the file.

Cheers
Bruce

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11310
    • View Profile
Re: Avoid downloaded file been served from browser cache
« Reply #2 on: May 13, 2025, 06:45:39 AM »
try
    p_web.HeaderDetails.ContentDisposition =  'attachment; filename="'& CLIP(Loc:DownloadFileName) &'"'
    p_web.HeaderDetails.CacheControl = 'no-store, no-cache, must-revalidate, private,post-check=0, pre-check=0, max-age=0'


Poul Jensen

  • Full Member
  • ***
  • Posts: 247
    • View Profile
    • Email
Re: Avoid downloaded file been served from browser cache
« Reply #3 on: May 13, 2025, 07:02:50 AM »
try
    p_web.HeaderDetails.ContentDisposition =  'attachment; filename="'& CLIP(Loc:DownloadFileName) &'"'
    p_web.HeaderDetails.CacheControl = 'no-store, no-cache, must-revalidate, private,post-check=0, pre-check=0, max-age=0'


Thanks Bruce - this did it.

/Poul