NGINX as proxy before apache, and localy store php generated images

Igor Sysoev igor at sysoev.ru
Fri Sep 28 09:42:00 UTC 2012


On Sep 28, 2012, at 13:31 , Jaroslav wrote:

> I am afraid they not :( 
> 
> Those images by default are expiring in epoch. 
> You want to say than nginx will handle this 304 thing if those headers are correctly set in PHP? 

Not nginx but browsers: they do not send If-Modified-Since/If-None-Match header fields to nginx.
If these images never expire then you can add

location /bin/ {
    expires 7d;
    add_header  ETag  '"anything"';


--
Igor Sysoev
http://nginx.com/support.html

> Can this be 'fixed' without touching php code? 
> 
> Thank you
> 
> On 28 September 2012 12:24, Igor Sysoev <igor at sysoev.ru> wrote:
> On Sep 28, 2012, at 13:15 , Jaroslav wrote:
> 
>> Thank you very much Igor for a fast response!
>> 
>> So far I see the performance increase. I see the logs being created. And no longer see so lot access logs to apache images.
>> 
>> my config is:
>>             location /bin/ {
>>                 expires 7d;
>>                 add_header X-Cache "Backend2-cache";
>>                 proxy_pass http://site.com;
>> 
>>                 proxy_cache my-cache;
>>                 proxy_cache_valid  200 302  360m;
>>                 proxy_cache_valid  404      1m;
>>             }
>> 
>> One more question is left in my mind, I see the expire headers are set, but the HTTP response status is always 200. 
>> is there somewhere a way to make it respond with status 304 (not modified) ? 
> 
> Do these images have "Last-Modified" or "ETag" header field ? 
> 
> 
> --
> Igor Sysoev
> http://nginx.com/support.html
> 
>> Thank you
>> 
>> On 28 September 2012 11:26, Igor Sysoev <igor at sysoev.ru> wrote:
>> On Sep 28, 2012, at 12:10 , Jaroslav wrote:
>> 
>>> Hello everyone,
>>> 
>>> I am using nginx as proxy before apache a long time already. And it is really terrific what it does.
>>> Ram usage dropped like 3 times
>>> I mainly set up image cache headers in nginx config
>>> 
>>> Today I've spotted, that one of vhosts is generating images ALWAYS on the fly, images are accessed like: 
>>> /bin/825?w=121&h=87&cutted=fit
>>> /bin/4999?w=222 
>>> /bin/5113?w=121&h=87&cutted=fit
>>> 
>>> etc..
>>> 
>>> I wonder is there any way I can tell nginx to store those images locally, ie for a week, and serve them
>>> to other users, so it won't be resized multiple times?
>>> 
>>> I tried googling but don't even know how/where to start from..
>> 
>> http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache
>> 
>> 
>> --
>> Igor Sysoev
>> http://nginx.com/support.html
> 
> 
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
> 
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20120928/d4deb708/attachment-0001.html>


More information about the nginx mailing list