delete cache

Just starting out? Need help? Post your questions and find answers here.
User avatar
William Van Hoecke
Posts: 50
Joined: Tue Oct 22, 2019 12:09 pm

Re: delete cache

Post by William Van Hoecke »

Peter wrote: Wed Feb 24, 2021 7:55 am

Code: Select all

LoadImage(#mypic,"myfolder/mypic17.jpg?rnd=" + ElapsedMilliseconds())
Peter I have a similar issue with my web-app
The webapp starts in the browser then checks its version on my server.
If its version does not correspond (old cached version) it pops up a window telling the custumer to press Ctrl F5 to force the browser to get a fresh version.
This works fine. However... on an android browser (smartphone or tablet) there is no ctrl F5 or any other quick way to clear cached version of a page and force loading fresh one.

So I tried to automate it like you suggest...

Code: Select all

dest.s= "https://www.myserverdomain.be/myspiderbasicwebapp.html?" + StrF(ElapsedMilliseconds())
!window.location.assign(v_dest)
The timestamp after the questionmark changes everytime but still the old cashed version is loaded instead of the new one

Any other ideas
hoerbie
Posts: 100
Joined: Sun Mar 17, 2019 5:51 pm
Location: DE/BY/MUC

Re: delete cache

Post by hoerbie »

Hi,

what web server do you use? If it is Apache, you could stop caching for your app-html with a .htaccess file.

The following stops every caching for all files in the dir, where you put the .htaccess in.

Code: Select all

<IfModule mod_headers.c>
  Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
  Header set Pragma "no-cache"
  Header set Expires 0
</IfModule>
Or you can only stop caching for your file, if you put the following .htaccess by side to your file:

Code: Select all

<Files myspiderbasicwebapp.html>
  <IfModule mod_headers.c>
    Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
    Header set Pragma "no-cache"
    Header set Expires 0
    Header Unset ETag
  </IfModule>
  FileETag None
</Files>
Or you could put a simple PHP wrapper around the download of your file, and let php send the no-caching headers.

Greets, hoerbie
User avatar
William Van Hoecke
Posts: 50
Joined: Tue Oct 22, 2019 12:09 pm

Re: delete cache

Post by William Van Hoecke »

hoerbie wrote: Tue Dec 14, 2021 8:18 am Hi,

what web server do you use? If it is Apache, you could stop caching for your app-html with a .htaccess file.

The following stops every caching for all files in the dir, where you put the .htaccess in.

Code: Select all

<IfModule mod_headers.c>
  Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
  Header set Pragma "no-cache"
  Header set Expires 0
</IfModule>
Or you can only stop caching for your file, if you put the following .htaccess by side to your file:

Code: Select all

<Files myspiderbasicwebapp.html>
  <IfModule mod_headers.c>
    Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
    Header set Pragma "no-cache"
    Header set Expires 0
    Header Unset ETag
  </IfModule>
  FileETag None
</Files>
Or you could put a simple PHP wrapper around the download of your file, and let php send the no-caching headers.

Greets, hoerbie
Thanks Hoerbie,
My server is indeed an apache and I will keep the .htaccess settings in mind and try that later...
However Paul mentioned that evendough you prevent the html page to be cached the called jave scripts still are !!!!
hoerbie
Posts: 100
Joined: Sun Mar 17, 2019 5:51 pm
Location: DE/BY/MUC

Re: delete cache

Post by hoerbie »

William,

I think you can use the htaccess way also to stop caching of the SB .js file of Peters tip.
If the SB .js file is in the same directory as the .html file, then the first block of my last post should help (but maybe is to much).
Or you simply can make a second "Files" block for the main .js file, or you can use one "FilesMatch" block for the .html and the .js file.

We have our own servers with a full self setup apache conf, and we never had problems.

Greets, hoerbie
User avatar
William Van Hoecke
Posts: 50
Joined: Tue Oct 22, 2019 12:09 pm

Re: delete cache

Post by William Van Hoecke »

Thanks hoerbie

I found another solution.
My webapp now starts in two stages.
1) Never changing url that calls a small app that checks my server for the current name of the main app.
whitch has its version number append to its name.
2) The small app finally calls the main app.
This way if I make version changes the name changes too and it can never be in one's cache.

However still having problems with cached images that may change but keep the same name !!!
So... I may have to consider your .htaccess suggestions anyway
Thans
Post Reply