如何使用 Memcached 配置 NGINX 来提供 HTML
我正在尝试使用 Memcached 配置 NGINX 来提供 HTML
我发现以下适用于 NGINX 的 Memcached 模块:
http://wiki.nginx.org/NginxHttpMemcachedModule
但我似乎无法让 NGINX 为我的 HTML(例如 index.html)文件提供服务来自 Memcached,阅读上面的教程。
有人知道 NGINX 配置应该是什么,才能从 Memcached 提供 HTML 服务吗?
I'm trying to configure NGINX with Memcached to serve HTML
I found the following Memcached module for NGINX:
http://wiki.nginx.org/NginxHttpMemcachedModule
But I can't seem to get NGINX to serve my HTML (e.g. index.html) files from Memcached from reading the tutorial above.
Anyone know what the NGINX config should be to bet it to serve HTML from Memcached?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要像这样将 memcached 与 nginx 一起使用,您需要使用正确的键/值对填充 memcached。为此,您将需要 @fallback 位置来为您做一些工作。
当匹配的请求到来时,nginx 将使用您设置的 $memcache_key 来查询 memcached。如果找到该值,则会将其发送到浏览器。如果不是,后备位置会调用您的后端系统执行两件事:
生成响应并将其发送回浏览器。
将响应发送到memcached并设置适当的键/值对。
下次请求相同密钥时,它将存储在 memcached 中,并直接从那里提供服务。
To use memcached with nginx like this you will need to populate memcached with the right key/value pairs. To do this you will need the @fallback location to do some work for you.
When a matching request comes in, nginx will query memcached with whatever you set $memcache_key to. If the value is found it is sent to the browser. If not the fallback location invokes your backend system to do two things:
generate a response and send it back to the browser.
send the response to memcached and set the appropriate key/value pair.
The next time a request comes in for the same key it will be in memcached and will be served directly from there.