我可以强迫我的样式表文件的刷新? [英] Can I force a refresh of my stylesheet file?

查看:115
本文介绍了我可以强迫我的样式表文件的刷新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚花了半天悄悄地要疯了。

I have just spent half a day quietly going mad.

我正在改变我的文件的site.css类和他们没有被反映在网站我的机器上正在开发中。因为我通过学习jQuery的我的方式和addClass与removeClass移除玩,我动态创建这些调用的参数,我相信这个问题是我的实现。

I'm making changes to my classes in the Site.css file and they were not being reflected in the site being developed on my machine. Because I'm learning my way through jQuery and playing with addClass and removeClass and I'm creating the parameters for those calls dynamically, I was sure the problem was in my implementation.

原来的CSS文件是在浏览器缓存和所有我需要做的就是刷新...

Turns out the CSS file was cached in the browser and all I had to do was refresh it...

有没有一种方法(仅在调试我猜preferably)强制刷新?

Is there a way to force a refresh (preferably only during debug I guess)?

推荐答案

缓存破的一个常用的方法是将参数追加到你的CSS源。通常使用的时间戳。我preFER文件最后修改时间,即。 filemtime()在PHP。我敢肯定有,会给你一个asp.net的功能。

A popular way of "cache-breaking" is to append a parameter to your css source. Typically a timestamp is used. I prefer the "file last modified" time, ie. filemtime() in PHP. I'm sure there's an asp.net function that would give you that.

然后你的CSS代码就变成了:

Then your CSS tag becomes:

<link rel="stylesheet" type="text/css" media="screen" href="/main.css?123456789"/>

与查询参数变化时CSS文件被更新。

with the query parameter changing whenever the CSS file is updated.

这篇关于我可以强迫我的样式表文件的刷新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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