HTML - 如何检查文件(或名为.js的CSS)的加载或从缓存回升? [英] HTML - How can I check if a file (.js or .css) was loaded or picked up from the cache?

查看:182
本文介绍了HTML - 如何检查文件(或名为.js的CSS)的加载或从缓存回升?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我需要一种方法来强制浏览器加载总是.css和.js文件。我解决它通过把一个sufix中的文件:

First, I needed a way to force browser always load .css and .js files. I solved it by putting a sufix in the files:

<script type="text/javascript" src="file.js"></script>

<script type="text/javascript" src="file.js?v=1"></script>

这aparently工作。

That aparently worked.

现在,我需要知道,如果真的奏效。当然,我可以编辑该文件,并检查在我的浏览器中的变化,但我需要一种方法更具体的,像在浏览器中,显示/从文件夹中加载新的文件,从缓存加载文件的选项。

Now, I need to know if that really worked. Sure, I can edit the file and check the changes in my browser but I need a way more specific, something like an option in the browser that show "File loaded from the cache" / "New file loaded from the folder".

你能帮助我吗?

推荐答案

这是浏览器的责任区从服务器加载资源,或把它从缓存。从客户端code你不能确定实际使用(如果你不加载动态使用AJAX资源)的来源。只有你能看是在开发者工具(或萤火虫)网络选项卡。

It is browser responsibility area to load resources from server or take it from cache. From client code you cannot determine the source that was actually used (if you don't load resources dynamically using ajax). Only you can is look at the Network tab in Developer Tools (or Firebug).

这篇关于HTML - 如何检查文件(或名为.js的CSS)的加载或从缓存回升?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆