样式表更改后缓存清除问题 [英] Cache clear problem after style sheet changes

查看:114
本文介绍了样式表更改后缓存清除问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

对于测试人员来说,在网站上更新任何样式更改时测试任何问题以清除缓存,临时文件是一种非常普遍的做法.

而且我们不能期望最终用户看到相同的操作.
目前,我们在我们的项目中正面临着这个问题.

那么,在部署过程中我们可以遵循哪些不同的方式或技术来反映更改而又不清除浏览器上的缓存或临时文件?

任何帮助或建议将不胜感激.

谢谢,
Tadit.

解决方案

有一种方法可以自动执行,

在组装中,设置版本号.

在后面的代码中,获取程序集版本

protected string getversion()
{
    return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
}



在aspx中,

<link rel="stylesheet" href="../css/test.css?<%= getversion(); %>" type="text/css" />



欢呼


如果您真的希望最终用户更快地看到样式更改,请更改样式表的名称,以便浏览器知道它是新样式.就个人而言,一旦发布了一些东西,我希望它能正常工作,而且如果最终用户稍微看一下旧样式,我不会觉得这有什么大问题.

您的另一个选择是设置缓存控制:"无缓存,必须重新验证" [ ^ ]

最好的技术是对CSS和js文件使用版本控制.

<script type="text/javascript" src="../js/test.js?1.1.1.1" ></script>

<link rel="stylesheet" href="../css/test.css?1.1.1.1." type="text/css" />



欢呼


Hi all,

It is a very common practice for the testers while testing any issue to clear cache, temporary files, when any styling changes are updated on the website.

And we can''t expect the same action from the end users to see the changes.
Currently we are facing this issue in our projects.

So, what are the different ways or techniques we can follow while deployment to reflect the changes without clearing the cache or temporary files on browsers ?

Any help or suggestion will be appreciated.

Thanks,
Tadit.

解决方案

There is a way to do it automatically,

In Assembly, set the version number.

in code behind, get the assembly version

protected string getversion()
{
    return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
}



In aspx,

<link rel="stylesheet" href="../css/test.css?<%= getversion(); %>" type="text/css" />



cheers


If you really want end users to see the style changes quicker, change the name of the style sheet, so the browser knows it''s a new one. Personally, once I release something, I expect that it works fine, and if end users look at the old style for a bit, I don''t see a huge issue with that.

Your other option is to set ''cache-control: "no-cache, must-revalidate"''[^]


The best technique is to use versioning to your css and js file.

<script type="text/javascript" src="../js/test.js?1.1.1.1" ></script>

<link rel="stylesheet" href="../css/test.css?1.1.1.1." type="text/css" />



cheers


这篇关于样式表更改后缓存清除问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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