是否有办法检查页面是否从浏览器缓存中加载?

时间:2022-11-19 12:11:05

The issue the question originates from is the following. I'm using TiddlyWiki (Classic) SPA on my Android device and usually use it with FireFox and its TiddlyFox extension for saving. For some reasons I'd like to be able to work with (and save) my TWs using other browsers, so I'm testing it with a PHP back-end (my fork of MicroTiddlyServer, but its code is not important here, I believe, + this PHP server).

问题产生的原因如下。我在我的Android设备上使用TiddlyWiki(经典)SPA,并且通常在FireFox和它的TiddlyFox扩展上使用它来保存。出于某些原因,我希望能够使用其他浏览器处理(并保存)TWs,所以我正在使用PHP后端(我的MicroTiddlyServer分支,但我认为它的代码在这里并不重要,加上这个PHP服务器)对它进行测试。

In my tests I've noticed that although saving works fine, sometimes (at least when the PHP server is unloaded from memory due to this ugly Android "optimization" which seems to be not configurable) a TW is loaded from cache and because of that it is loaded as it was before the latest saving, not after.

在我的测试中我注意到,尽管储蓄也好用,有时(至少在PHP服务器从内存中卸载是因为这丑陋的Android“优化”,似乎是不可配置的)TW从缓存加载,因为它加载之前最新的储蓄,而不是之后。

So, what I want is to detect if the page was loaded in an ordinary way or from browser cache. Is it possible to check this via JavaScript?

因此,我想要的是检测页面是以普通的方式加载,还是从浏览器缓存加载。是否可以通过JavaScript检查?

As a worse alternative I can inject a timestamp via MTS and check it in a TW on load, but I'd like to avoid this complication (which involves both front-end and back-end and adds more TW file manipulation).

作为一种更糟糕的选择,我可以通过MTS注入时间戳,并在TW加载时检查它,但是我希望避免这种复杂性(包括前端和后端,并添加更多TW文件操作)。

1 个解决方案

#1


0  

If you use the remote debugger in chrome you can see the network requests and determine if you item is cached or not. Firefox seems to have a remote debugger as well.

如果您在chrome中使用远程调试器,您可以看到网络请求,并确定您的项目是否被缓存。Firefox似乎也有一个远程调试器。

#1


0  

If you use the remote debugger in chrome you can see the network requests and determine if you item is cached or not. Firefox seems to have a remote debugger as well.

如果您在chrome中使用远程调试器,您可以看到网络请求,并确定您的项目是否被缓存。Firefox似乎也有一个远程调试器。