简体   繁体   English

PHP + Nginx + X-Accel-Redirect缓存问题

[英]PHP + Nginx + X-Accel-Redirect Caching issue

I am using nginx 1.0.12 and have a setup like this: 我正在使用nginx 1.0.12并具有如下设置:

        location /protected/ {
            expires 30d;
            log_not_found off;
            internal;
            alias /var/www/files/uploads/;
    }

and am requesting user files like this: 并要求这样的用户文件:

header('X-Accel-Redirect: http://example.com/adetwiler/files/example.png');
header('Content-type: image/png');

Everything works great up until the point where the user can rotate their image. 一切正常,直到用户可以旋转其图像为止。 Once they rotate their image, I can't figure out how to get the "new" version of the file, it's still showing the older version of the image, unless "refresh" is clicked on the browser. 一旦他们旋转了图像,我就不知道如何获取该文件的“新”版本,除非在浏览器中单击“刷新”,否则它仍显示该图像的旧版本。

I have tried to set Cache-control: no-cache, Expires: Expires: Sat, 26 Jul 1997 05:00:00 GMT, no luck with those. 我尝试设置Cache-control:no-cache,Expires:Expires:Sat,1997年7月26日,格林尼治标准时间,格林尼治标准时间,没有运气。

I tried adding the modified date like so: 我尝试添加修改日期,如下所示:

header('X-Accel-Redirect: http://example.com/adetwiler/files/example.png?123456789');

That caused the image to load everytime when I tried that. 每次尝试加载时都会导致图像加载。

I tried adding this to the nginx config: 我尝试将其添加到nginx配置中:

add_header Pragma public;
add_header Cache-Control "public, must-revalidate";

At this point I am at a loss, I have tried everything that I could think of. 在这一点上,我很茫然,我已经尝试了所有我能想到的。

So my question is, is there a way with my current setup or something similar to my setup to use the newer version of the image once the image is updated? 所以我的问题是,一旦图像更新,当前的设置或与我的设置类似的方法是否可以使用图像的新版本?

Thanks! 谢谢!

It looks like setting X-Accel-Buffering: no as a header tells nginx not to cache the response at all. 看起来像设置X-Accel-Buffering: no因为标头告诉nginx根本不缓存响应。

https://www.nginx.com/resources/wiki/start/topics/examples/x-accel/ https://www.nginx.com/resources/wiki/start/topics/examples/x-accel/

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM