is there an effective way to clear the cache?
-
- Posts: 120
- Joined: Tue Jun 14, 2016 7:17 pm
is there an effective way to clear the cache?
I made a web menu for a customer, he always asks me to make changes to the menu, and every time I update it's a huge problem, because we can't make restaurant customers "know how to clear the browser cache, because most are technology laymen " , is there an effective way to prevent the cache from getting in the way of page refresh done in SB ?
-
- Posts: 284
- Joined: Fri Sep 22, 2017 7:02 am
Re: is there an effective way to clear the cache?
There are many browsers out there, with different ways to clear the cache.
Perhaps it is better not to cache certain files or to keep giving them new names during deployment. For example, with a timestamp...
Just as an idea...
Perhaps it is better not to cache certain files or to keep giving them new names during deployment. For example, with a timestamp...
Just as an idea...
Re: is there an effective way to clear the cache?
I don't know if it would be suitable for your application, but inserting:
should force a reload, ignoring the cache.
Code: Select all
!window.location.reload(true);
-
- Posts: 120
- Joined: Tue Jun 14, 2016 7:17 pm
Re: is there an effective way to clear the cache?
how can i use this ? when I try to use it, the page keeps reloading infinitely, is there a way to stop this command from running?KianV wrote: ↑Sun Jun 27, 2021 3:52 pm I don't know if it would be suitable for your application, but inserting:should force a reload, ignoring the cache.Code: Select all
!window.location.reload(true);
I've tried it, but it didn't work :cDirk Geppert wrote: ↑Sun Jun 27, 2021 9:33 am There are many browsers out there, with different ways to clear the cache.
Perhaps it is better not to cache certain files or to keep giving them new names during deployment. For example, with a timestamp...
Just as an idea...
Re: is there an effective way to clear the cache?
It needs to be triggered by an Event in the program. This could be clicking on something or when any graphics are finished loading &c..skinkairewalker wrote: ↑Sun Jun 27, 2021 8:15 pm how can i use this ? when I try to use it, the page keeps reloading infinitely, is there a way to stop this command from running?
When this should happen depends very much on the program itself, and when it would be most appropriate.
-
- Posts: 120
- Joined: Tue Jun 14, 2016 7:17 pm
Re: is there an effective way to clear the cache?
do u have some code example ?
Re: is there an effective way to clear the cache?
Without seeing exactly what your code does, it is difficult to say, but the following should work under all circumstances.
This stores a value in sessionStorage to show that the reload has been done.
The value is stored as long as the window/tab is open. Therefore, when someone comes back to the page again, the value will be lost and the reload will be performed.
I suspect that many people keep the browser on their phones open nearly permanently, so I would suggest putting something at the end - when changing page or checkout or somesuch - to clear the value, just in case.
e.g. !sessionStorage.setItem("pageupdated", "False");
Code: Select all
OpenWindow(0, 100, 100, 320, 200, "Window 0")
TextGadget(0, 10, 70, 300, 20, "This is just to put something on the screen", #PB_Text_Center )
ismenuupdated.s=""
!var v_ismenuupdated = sessionStorage.getItem("pageupdated");
;retrieve value from sessionStorage
If ismenuupdated="True"
Debug "it is already updated"
Else
Debug "updating the page now"; if value retrieved is not 'True", reload window ignoring cache
!window.location.reload(true);
!sessionStorage.setItem("pageupdated", "True");
;set value in sessionStorage To 'True'
EndIf
; Put the rest of your code here
Procedure CloseWindowEvent()
Debug "Closing window: " + EventWindow()
CloseWindow(EventWindow()) ; Close the specific window
EndProcedure
BindEvent(#PB_Event_CloseWindow, @CloseWindowEvent())
The value is stored as long as the window/tab is open. Therefore, when someone comes back to the page again, the value will be lost and the reload will be performed.
I suspect that many people keep the browser on their phones open nearly permanently, so I would suggest putting something at the end - when changing page or checkout or somesuch - to clear the value, just in case.
e.g. !sessionStorage.setItem("pageupdated", "False");
Re: is there an effective way to clear the cache?
The problem ist, that "!window.location.reload(true);" not really good works.
- William Van Hoecke
- Posts: 50
- Joined: Tue Oct 22, 2019 12:09 pm
Re: is there an effective way to clear the cache?
Same problem here...skinkairewalker wrote: ↑Sun Jun 27, 2021 2:05 am I made a web menu for a customer, he always asks me to make changes to the menu, and every time I update it's a huge problem, because we can't make restaurant customers "know how to clear the browser cache, because most are technology laymen " , is there an effective way to prevent the cache from getting in the way of page refresh done in SB ?
!window.location.reload(true); does not clear the cache it always reloads the same old page !
did you find a solution ?
Re: is there an effective way to clear the cache?
It is not enough to reload the HTML page. You must also ensure that the JavaScript is loaded without cache.
If you look at the HTML page generated by SpiderBasic, you will see the following line:
(spiderbasic.js can also have a different name, depending on what you have called your app)
This file must be reloaded bypassing the cash. If the SpiderBasic compiler appended a timestamp to the JavaScript file each time it generated the HTML file, this wouldn't be a problem.
I asked Fred in 2017 to build this into SpiderBasic; unfortunately without success until today: Attach a timestamp to the generated JavaScript
If you look at the HTML page generated by SpiderBasic, you will see the following line:
Code: Select all
<script type="text/javascript" src="spiderbasic.js"></script>
This file must be reloaded bypassing the cash. If the SpiderBasic compiler appended a timestamp to the JavaScript file each time it generated the HTML file, this wouldn't be a problem.
I asked Fred in 2017 to build this into SpiderBasic; unfortunately without success until today: Attach a timestamp to the generated JavaScript