浏览器(或者是 Visual Studio?)似乎正在缓存样式表,因此我所做的任何更改

发布于 2024-08-17 03:18:58 字数 320 浏览 5 评论 0原文


我使用样式表作为主题的一部分,似乎 IE 和 Firefox(或者 VS Express 版本)都在缓存此样式表,因为我对样式表所做的任何更改(例如更改属性值等)不会反映在显示的页面上。知道如何阻止浏览器或 Visual Studio 缓存此样式表吗?


顺便说一句 – 仅缓存样式表,而不缓存整个页面

另外,当我注意到对样式表所做的任何更改都没有反映在显示的页面上时,我已从 Firefox 切换到 IE。第一次在 IE 中加载页面时,页面按应有的方式显示(反映了我对样式表所做的所有更改),但随后 IE 也开始缓存样式

I’m using a stylesheet as part of a theme and it seems that both IE and Firefox ( or perhaps VS express edition) are caching this stylesheet, since any changes I make to a stylesheet ( such as changing attribute values etc ) aren’t reflected on the displayed page. Any idea how to prevent browser or visual studio from caching this stylesheet?

BTW – only stylesheet is cached, not the entire page

Also, when I've noticed that any changes made to a stylesheet aren’t reflected on a displayed page, I’ve switched from firefox to IE. The first time the page was loaded in IE, page was displayed as it should (reflecting all the changes I’ve made to the stylesheet), but then IE also started caching the stylesheet

thanx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

紫南 2024-08-24 03:18:58

如果您的 Firefox 带有 Web Developer 工具栏,您可以轻松禁用缓存。您也可以使用Ctrl+F5刷新页面。按住 Ctrl 会告诉浏览器执行忽略缓存的强制刷新。

If you have Firefox with the Web Developer toolbar, you can easily disable caching. You can also use Ctrl+F5 to refresh the page. Holding Ctrl tells the browser to perform a forced refresh that ignores the cache.

故事与诗 2024-08-24 03:18:58

一种选择是以不允许浏览器缓存样式表的方式链接到样式表。我发现在处理 Facebook 应用程序之类的事情时就是这种情况。

<link type="text/css" rel="stylesheet" href="/styles.css?v=<%= DateTime.Now %>" />

One option is to link to the stylesheet in a manner that doesn't allow the browser to cache it. I find this is th case when dealing with things like facebook apps and such.

<link type="text/css" rel="stylesheet" href="/styles.css?v=<%= DateTime.Now %>" />
喜你已久 2024-08-24 03:18:58

您可以尝试将版本号添加到 css href:

查询字符串 (v1.0.1) 不会影响 css,但如果数字增加,浏览器会重新加载样式表 (stylesheet.css)。

You could try adding version numbers to your css href:

<link rel="stylesheet" type="text/css" href="path/to/stylsheet.css?v1.0.1" />

The query string (v1.0.1) doesn't affect the css as such, but if the number increments the browser reloads the stylesheet (stylesheet.css).

待天淡蓝洁白时 2024-08-24 03:18:58

拥有汇编版本也是一个好主意:

[CB]

protected string GetAssemblyVersion()
{
    // get the version object for this assembly
    Version v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;

    // or do it in pieces
    return v.Major + "." + v.Minor + "." + v.Build +"." + v.Revision;
}

[MARKUP]

<link href="/path/to/style.css?v=<%=GetAssemblyVersion() %>" type="text/css" rel="stylesheet" />

Having the assembly version is also a good idea:

[CB]

protected string GetAssemblyVersion()
{
    // get the version object for this assembly
    Version v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;

    // or do it in pieces
    return v.Major + "." + v.Minor + "." + v.Build +"." + v.Revision;
}

[MARKUP]

<link href="/path/to/style.css?v=<%=GetAssemblyVersion() %>" type="text/css" rel="stylesheet" />
子栖 2024-08-24 03:18:58

这个人有一个脚本,您可以将其放置在您的asp页面中,FWIW

This guy has a script you can place in your asp pages, FWIW

俯瞰星空 2024-08-24 03:18:58

您可以尝试在单击刷新按钮时按下 Shift 按钮 - 这对我来说一直有效。

You can try hitting the shift button when you click the refresh button -- this always worked for me.

若有似无的小暗淡 2024-08-24 03:18:58

正如大家所说,按Ctrl+F5刷新页面。

如果这不起作用,那么这是您设计的页面还是在组中共享的项目的一部分?编写代码的人可能会经常缓存样式表或页面,以减少带宽消耗。

As everyone said, press Ctrl+F5 to refresh the page.

If that isn't working then, is this a page you designed or is it part of a project that is shared in the group? It's possible that who ever coded it might be caching the style sheets or page every so often to reduce bandwidth spent.

别忘他 2024-08-24 03:18:58

您可以尝试使用元标记来指示该页面似乎已过期。
例如:

<head id="Head1" runat="server">
    <title></title>    
     <meta http-equiv="CACHE-CONTROL" content="NO-CACHE, must-revalidate, max-age=0" />
     <meta http-equiv="expires" content="0" />
     <meta http-equiv="Pragma" content="no-cache" />
</head>

我发现浏览器并不总是考虑这些元标记。 IE 似乎最擅长检测页面不应被缓存/内容是否已过期。

否则,请刷新页面以按照已建议的方式重新加载内容。

-弗林尼

You could try using meta tags to indicate that the page is appears to be expired.
For example:

<head id="Head1" runat="server">
    <title></title>    
     <meta http-equiv="CACHE-CONTROL" content="NO-CACHE, must-revalidate, max-age=0" />
     <meta http-equiv="expires" content="0" />
     <meta http-equiv="Pragma" content="no-cache" />
</head>

I have found that these meta tags aren't always taken into consideration by browsers. IE seems to be the best at detecting that the page shouldn't be cached/the content is expired.

Otherwise, refresh the page to reload the content as has already been suggested.

-Frinny

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文