为什么Firefox有时缓存我的CSS& Javascript代码,即使它已经改变了吗? [英] Why does Firefox sometimes cache my CSS & Javascript code, even though it has changed?

查看:181
本文介绍了为什么Firefox有时缓存我的CSS& Javascript代码,即使它已经改变了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的产品网站上,Firefox有时会不检测我的CSS& Javascript代码。而是它加载旧版本,所以似乎我需要清除缓存。在这样的情况下,我该怎么办?这涉及最新的Firefox(在编写本文时为16.0.1)。

On my product site, Firefox sometimes "doesnt detect" changes in my CSS & Javascript code. Rather it loads the old versions, so it seems that I need to clear the cache. In a situation like this, what should I do? This relates to the latest Firefox (16.0.1 at the time of this writing.)

编辑!

我忘了说localhost css文件的错误。我的意思是,theres一个旧的js文件,我更新它,上传它,在产品服务器firefox认为它的localhost文件。
包含文件的方式:

I forgot to say it mistakes for the localhost css files. I meant, theres an old js file, I update it, upload it, and on product server firefox thinks its the localhost file. The way I include files:

<link rel="stylesheet" href="/xyz.css" type="text/css" />


推荐答案

如果您使用服务器端语言使用技巧。
您可以在.css / .js后面附加一个字符串。例如在PHP中:

If you are using a server-side language you could use a trick. You can append a string after .css/.js. In PHP for example:

<link rel="stylesheet" type="text/css" href="/style.css?t=<?= time(); ?>" />

每页重新载入都会改变。

It changes every page reload.

请参阅这篇关于的文章缓存清除

这篇关于为什么Firefox有时缓存我的CSS&amp; Javascript代码,即使它已经改变了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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