简体   繁体   English

为什么即使在发送无缓存标头后页面仍然缓存?

[英]Why is the page still caching even after the no-cache headers have been sent?

I've done a ton of research on this and have asked many people with help and still no success. 我已经对此做了大量研究,并向许多人提出了帮助,但仍然没有成功。 Here are the details... 这是详细信息......

I'm involved in developing a website that pulls data from various data files, combines them in a temp .csv file, and then is graphed using a popular graphing library: dygraphs. 我参与开发一个从各种数据文件中提取数据的网站,将它们组合在一个临时.csv文件中,然后使用流行的图形库绘制图形:dygraphs。 The bulk of the website is written in PHP. 该网站的大部分内容都是用PHP编写的。 The parameters that determine the data that is graphed are stored in the users session, the .csv is named after the users session and available for download, and then the .csv file is written in a script that passes it to the dygraphs object. 确定绘制数据的参数存储在用户会话中,.csv以用户会话命名并可供下载,然后.csv文件写入脚本,将其传递给dygraphs对象。 And we've found, even with the no-cache headers sent: 我们发现,即使发送了无缓存标头:

header("Cache-Control: no-cache, must-revalidate");  
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");

Many users experience in the middle of a session, (if enough different graphs are generated) the page displaying an older, static rendering of the page (data they had graphed earlier in the session) as if it were cached and loaded instead of getting a new request. 许多用户在会话中遇到(如果生成了足够多的不同图表)页面显示页面的较旧的静态呈现(他们在会话中早先绘制的数据),就像它被缓存和加载而不是获得新的要求。 It only gets weirder though: 它只会变得更奇怪:

I've checked using developer tools in both Firefox and Chrome and both browsers are receiving the no-cache headers just fine; 我已经在Firefox和Chrome中使用了开发人员工具进行了检查,两个浏览器都接收到了无缓存标头。 Even when the problem occurs if you view the page source, the source is the correct content (a table/legend is also dynamically created using php, the source shows the correct table, but what is rendered is older content); 即使在查看页面源时出现问题,源也是正确的内容(表/图例也是使用php动态创建的,源显示正确的表,但呈现的是旧内容); the page begins to render correctly until the graph is about to be display, and then shows the older content; 页面开始正确呈现,直到图表即将显示,然后显示较旧的内容; the older content displays as if it were a completely static overlay--the cached graph does not have the same dynamic features (roll over data point display, zoom and pan, etc.) And it is as if the correct page were somewhere beneath it (the download button for the csv file moves depending on how large the table is. The older, static page does nothing if you click the download .csv button, but if you can manage to find the one in the page beneath it you can click and still download the .csv. The data in the .csv is correct) 较旧的内容显示为完全静态的叠加层 - 缓存的图形没有相同的动态功能(滚动数据点显示,缩放和平移等)并且就好像正确的页面位于其下方的某处(csv文件的下载按钮会根据表的大小而移动。如果单击下载.csv按钮,较旧的静态页面不会执行任何操作,但如果您可以设置在其下方的页面中找到该页面,则可以单击并仍然下载.csv。.csv中的数据是正确的)

It is one of the strangest things I've seen in development thus far. 这是迄今为止我在开发中看到的最奇怪的事情之一。 Some other relevant facts are that all the problems I've personally experience occurred while I was using Chrome. 其他一些相关事实是我在使用Chrome时遇到的所有问题都发生了。 Non of these symptoms have been reported by Firefox users. Firefox用户报告了这些症状。 IE users have had the same problems (IE users are forced to use chrome frame). IE用户遇到了同样的问题(IE用户被迫使用chrome框架)。

I'm at my wits end at this point. 在这一点上,我的智慧结束了。 We've sent the php headers; 我们发送了php标头; we've tried setting the cache profile for php on IIS as "DisableCache" (or whatever); 我们已经尝试在IIS上为php设置缓存配置文件为“DisableCache”(或其他); we've tried sending a random query string to the results page; 我们已经尝试将随机查询字符串发送到结果页面; we've tried all the appropriate meta tags--all with no success. 我们已经尝试了所有适当的元标记 - 都没有成功。

Did you try the "Last-Modified" and "ETag"? 你尝试过“Last-Modified”和“ETag”吗? and only watch the HTTP Header about that graph. 并且只观看有关该图表的HTTP标头。

只要您的服务器忽略URL参数,您就可以通过获取“url.csv?(随机数)”而不是“url.csv”来绕过任何浏览器缓存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 发送标头后重定向用户 - Redirect a user after the headers have been sent BOM为何引起警告“标题已发送”? - Why does BOM cause warning “headers have already been sent”? Firefox实时HTTP标头,在Cache-Control之后使用大括号:no-cache - Firefox live http headers, curley braces after Cache-Control: no-cache 输出仍然有效后在php中发送的标头 - headers sent in php after output STILL working PHP会话添加标题实用程序:无缓存 - PHP Session Adding Headers Pragma: no-cache 头发送到客户端后,如何处理Symfony2中的Session? - How to handle Session in Symfony2 after headers have been sent to client? 即使在元标记上没有HTML缓存,Godaddy上的HTML仍然可以缓存 - HTML still caching even after meta tag no caching implementation on Godaddy Laravel响应Cache-Control标头始终包含'no-cache' - Laravel response Cache-Control headers always containing 'no-cache' “session_start(): 无法发送 session 缓存限制器 - 标头已发送”即使在 session_start() 已经位于顶部之后也会继续出现 - “session_start(): Cannot send session cache limiter - headers already sent” keep coming even after session_start() already on top “标头已发送”,但没有“输出开始于...” - "Headers have already been sent", but without "output started at ..."
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM