强制浏览器刷新css,javascript等 [英] Force browser to refresh css, javascript, etc

查看:185
本文介绍了强制浏览器刷新css,javascript等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过XAMPP开发基于Wordpress源代码的网站。有时我改变CSS代码,scrips或其他东西,我注意到我的浏览器需要时间来应用修改。这导致我使用多个浏览器来刷新一个,如果不应用新的样式,我尝试第二个,它总是这样。

I'm developing a website based on Wordpress source code through XAMPP. Sometimes I change the CSS code, scrips or something else and I notice my browser takes time to apply the modifications. This leads me to use multiple browsers to refresh one and if doesn't apply the new styles I try the second one and it's always this.

有一些方法可以避免这个问题?

There is some way of avoiding this problem? Sometimes I'm changing code without notice the previous modifications.

推荐答案

一般解决方案


b

Ctrl + F5 (或 Ctrl + Shift + R )强制缓存重新加载。我相信Mac使用 Cmd + Shift + R 。

General solution

Pressing Ctrl + F5 (or Ctrl + Shift + R) to force a cache reload. I believe Macs use Cmd + Shift + R.

在PHP中,您可以通过将过期日期设置为包含标题的过去时间来禁用缓存:

In PHP, you can disable the cache by setting the expiration date to a time in the past with headers:

header("Expires: Tue, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");



Chrome



Chrome的快取可以停用通过打开 F12 开发工具,点击右下角的齿轮图标,然后在设置对话框中选择禁用缓存,如下所示:

Chrome

Chrome's cache can be disabled by opening the developer tools with F12, clicking on the gear icon in the lower right corner and selecting Disable cache in the settings dialog, like this:



图片取自此答案

在网址列中键入 about:config ,然后找到标题为 .http.use-cache 。将此设置为 false

Type about:config into the URL bar then find the entry titled network.http.use-cache. Set this to false.

这篇关于强制浏览器刷新css,javascript等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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