Wrong cache key for SSI-subrequests with FastCGI

谁说胖子不能爱 提交于 2021-01-29 11:38:05

问题


When I use SSI, NGinx uses the wrong cache key for the subrequest

fastcgi_cache_key       "$request_method $scheme://$host$uri";

The problem is, that it ends up in an infinite recursion, because on the main request NGinx stores the page including the SSI-element in its cache and then when it triggers the subrequest, uses this page (including the SSI-element) as result of the subrequest (and so on and so on). I thought $uri is exactly designed to avoid this (unlike $request_uri), but obviously it doesn't work.

nginx version is 1.3.8


回答1:


A slightly longer debug-session (the nginxs debug-logs are ... big) gave me the answer: It was not the cache-key directly, but by default the REQUEST_URI is set to $request_uri in /etc/nginx/fastcgi_params. The cache key is correct, but the request is always identical to the parents one, so the parent page is cached twice: Once for the parent-uri-key and once for the ssi-subrequest. On every subsequent call the (broken) cached values is used.

fastcgi_param REQUEST_URI $uri;


来源:https://stackoverflow.com/questions/14553726/wrong-cache-key-for-ssi-subrequests-with-fastcgi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!