SHWotever / SimHub

Multi sim dashboard, bass shaker driver, ....
http://www.simhubdash.com/
764 stars 96 forks source link

[QUESTION] Force delete Web Component Cache #1252

Closed FullPace closed 1 year ago

FullPace commented 1 year ago

I'm wondering how simhub caches content of the web component. I use it to display an image when an update for the dashboard is available. but even renaming img with paramenters like update.jpg?=v102 does not help to make simhub reload the content. once it's cached it's there forever ...

Any tips how to force reload contents?

SHWotever commented 1 year ago

Hi ! It uses internally a chromimum based webbrowser so all the the usual caching rules applies (cache control etc ....) In theory cache busting like you did ?v=102 should be sufficient, but it really depends of how the request gets processed (redirects ...)

Do you have a sample with the issue so I can take a look how the requests gets processed ?

FullPace commented 1 year ago

Here's all I have: 1.) Dashboard (web component is on idle screen) https://www.racedepartment.com/downloads/pacelogic-pro.58473/

Attached are the html files I use, You can load them from local Simhub "Web" folder as well. The problem remains.

To reproduce: Open dashboard once, then change web component html file (you can also delete all content in body) re-open dashboard --> Old content of web component is still there.

Only if you change the url to the other filename it changes content once.

HTML Files.zip

SHWotever commented 1 year ago

Thanks ! I tested the url https://www.fullpace-simracing.com/assets/external/pacelogic-pro-v1.1.html

Despite the html head caching instructions, chrome is caching it :

image

That means that simhub behavior is normal about that page.

From my experience you are having contradictory headers, on one side you have html headers asking not to cache , but the requests header themselves exposes some caching headers : image

To get sure not to cache you need to add a no cache response headers : Cache-Control: no-cache

This is usually done in htaccess files or web.config for a microsoft server . https://developer.mozilla.org/fr/docs/Web/HTTP/Headers/Cache-Control

In theory if you are using a php server just changing the extension to .php should trigger default "no caching" rules in your server as .php is a dynamic file extension.

SHWotever commented 1 year ago

In the context of a vocore screen I have hand on the browser itself so I could force the cache to be flushed etc ... but on a browser like a phone or chrome it's the natural browser behavior which will occur so the only proper and consistent way is to make the request response non cacheable as i've explaned above.

FullPace commented 1 year ago

Thank you, I'll try changing to php and see if this helps. I played with a lot of header commands, to see if any of them improves the refreshing of the cache. Since this is all bandwith on my server, caching isn't bad at all. It would just be nice to have control over the cache to notify about the updates.

The dashboard is indeed made for a Vocore device but I think it's such a special need, it's probably not worth puttin extra time into it.

SHWotever commented 1 year ago

With the proper htaccess it's possible to target only the ressources you want to avoid. Alternatively using a dedicated folder with its own htaccess can do the trick. Caching can be hell sometimes. Simhub internally use lot of cache busting query strings, the balance between caching at the right time Vs refreshing at the right time is always hard to reach.

FullPace commented 1 year ago

I tried changing the link to .php but it's not loading anything (tested local in simhub > web folder). I guess web component only supports html then?

SHWotever commented 1 year ago

Ah simhub embedded server is not a php compliant server, simhub is using a light asp.net internal server it won't recognize .PHP indeed, only a real php server will do it. Your site https://www.fullpace-simracing.com/ might be one, it's the most common technology available in hosting services.

SHWotever commented 1 year ago

And overall simhub internal server has a deliberately extremely aggressive caching strategy to improve loading time when reloading dash's etc.