cache doesn't work with my website

22 views
Skip to first unread message

Saada Mehdi

unread,
Nov 20, 2022, 12:08:50 PM11/20/22
to Chromium-discuss
Hi,
I am positive caching doesn't work on my website (because it's way too slow), and doesn't know why, nor do I even know whether or not a specific ressource is loaded from the cache or the network.

Thanks

Jon Perryman

unread,
Nov 20, 2022, 2:16:16 PM11/20/22
to 0012...@gmail.com, Chromium-discuss
Learn to use developer tools and work with your web server developer. Developer tools can tell you what is slow and what is happening. It will show you if the request is referencing cache or if it's sending the request to the server. Is the server responding  with HTTP 304 (not modified)?  How long are the requests taking? Does the problem occur in Firefox or Safari (ignore chromium based browsers like MS Ed, Brave or ...). You need to do some basic debugging before anyone can help you. . 

--
--
Chromium Discussion mailing list: chromium...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-discuss

---
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-discu...@chromium.org.

PhistucK

unread,
Nov 20, 2022, 6:09:55 PM11/20/22
to jon.pe...@gmail.com, 0012...@gmail.com, Chromium-discuss
Looked out of curiosity and your service worker has this -
 event.respondWith(fetch(request).then(saveToCache).catch(serveFromCache));

Seems like it always requests from the network and always saves it in the cache. As far as I know, saving it in caches will not prevent the fetch event or the request - it is on you to load it from the cache within the fetch event.
In other words, caches is not an API for the normal browser cache, it is an API for you to store requests and load them when you want to.

PhistucK

Saada Mehdi

unread,
Nov 21, 2022, 4:58:06 AM11/21/22
to PhistucK, jon.pe...@gmail.com, Chromium-discuss
but that kind of cache is completely useless, what the hell is this... Is this chromium's fault, or my site ? If my site, then it's actually the hugo static site generator.What should I modify and where, to get it to use the browser's cache if it hasn't expired ?
As far as I understood your lengthy but appreciated explanation, this API `caches` is only called forth when the site can't be reached. Pretty much useless ,so.

PhistucK

unread,
Nov 21, 2022, 6:00:21 AM11/21/22
to Saada Mehdi, jon.pe...@gmail.com, Chromium-discuss
No, the caches API is not called when the site cannot be reached.
It is simply not an automatic cache mechanism.
It is an author-controlled, rather than browser-controlled caching mechanism. The author (the developer) decides what to cache, when to cache (and can version things, too) and what to load from that cache and when.


This is not a Chromium issue (it should happen in every browser that supports the API), this is what the API is intended to do. If the service worker is entirely generated by that static site generator, it might be a configuration issue, or a bug in the generator.

Not having a service worker at all might cache things normally (have not looked). Otherwise, https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers can explain things.



PhistucK

Jon Perryman

unread,
Nov 21, 2022, 11:44:57 AM11/21/22
to PhistucK, Saada Mehdi, Chromium-discuss
To simplify this for Saada, this is your site's problem. A service worker is javascript included with your web page. This API is useful if you understand how to use it. Since we don't know your web site's intent, we can't say why you decided to code this statement. If you did not code this statement, then you probably included it from a package you are using on your web  page. 
Reply all
Reply to author
Forward
0 new messages