【发布时间】:2017-08-19 21:08:42
【问题描述】:
我正在为我的网站使用 ASP.NET 和 IIS。最近,我通过 Google 找到了 Varnish Cache 软件,一个出色的缓存 HTTP 反向代理。
清漆缓存安装在 Ubuntu 16.04.1 上,然后我配置 IIS 连接到它。那太棒了。
Varnish Cache 具有Purge 功能,可以清除指定页面或所有站点的所有缓存。在 ASP.NET 上,我编写了代码,使用 PURGE 方法创建了一个对 Varnish 缓存服务器的请求,并发生错误: 远程服务器返回错误:(405) Method Not Allowed。
这是我的代码:
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://IP-Address-Varnish-Cache-Server");
req.Method = "PURGE";
using (HttpWebResponse resp = (HttpWebResponse)req.GetResponse())
{
// get the page data
using (StreamReader sr = new StreamReader(resp.GetResponseStream()))
{
string html = sr.ReadToEnd();
}
}
请帮我解决上述错误?谢谢。
【问题讨论】:
-
你能分享你的清漆 vcl_recv 代码吗?您似乎没有在其中处理 PURGE 请求。
标签: c# asp.net ubuntu caching varnish