Javascript HTTP缓存头
我有一些javascript代码可以在网页中动态加载图像:Javascript HTTP缓存头,javascript,http,http-headers,Javascript,Http,Http Headers,我有一些javascript代码可以在网页中动态加载图像: imageSrc = pid.toString() + '/' + imageName + '/' + num.toString(); //imageSrc = pid.toString() + '/' + imageName; 第一行工作正常,但使用第二行会导致图像在加载后不会更改。我使用firebug从服务器捕获标题: Content-Length 43 Allow GET, HEAD Expires Sun, 28 Ja
imageSrc = pid.toString() + '/' + imageName + '/' + num.toString();
//imageSrc = pid.toString() + '/' + imageName;
第一行工作正常,但使用第二行会导致图像在加载后不会更改。我使用firebug从服务器捕获标题:
Content-Length 43
Allow GET, HEAD
Expires Sun, 28 Jan 2007 00:00:00 GMT
Server CherryPy/3.1.2
Pragma no-cache
Cache-Control no-cache, must-revalidate
Date Sun, 13 Feb 2011 21:12:31 GMT
Content-Type image/x-png
我还添加了一行
到网页的头部
这个问题发生在firefox、IE和chrome中,所以我认为这一定是一个根本问题,而不是浏览器问题。任何帮助都将不胜感激。破坏缓存的典型方法是附加一个搜索字符串(请注意PNG后面的问号): 顺便说一句,您不需要执行.toString(),因为将变量添加到一起会使它们成为字符串:
"a" + 1 + 1; // "a11"
我认为这种技术的问题在于浏览器仍然在缓存imagea,导致客户端内存泄漏。而且,我仍然很好奇为什么所有的浏览器似乎都忽略了http头?
"a" + 1 + 1; // "a11"