我有一个 iis 处理程序,它为 .txt 文件提供 context.Response.ContentType = "text/plain";
如何防止内容被 google 或任何搜索引擎缓存(应该允许索引,所以我不想将其添加到 robots.txt)?
有没有一种方法可以将 nocache header 添加到 context.Response.ContentType = "text/plain"
;
我有 context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
但这不会阻止搜索引擎缓存内容。
最佳答案
该 header 控制客户端缓存,而不是搜索引擎缓存。你需要设置
Response.AppendHeader("X-Robots-Tag", "noarchive");
Do not show a "Cached" link in search results.
关于c# - 如何防止搜索引擎缓存提供的自定义处理程序 "text/plain"类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27335261/