Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Stop caching images on a rewrite with NGINX

$
0
0
Hey, I posted for help on stackoverflow quite a while back and got no reply, so i'm hoping some of you guys can help me out. You can see my post here: http://stackoverflow.com/questions/19434656/stop-caching-images-on-a-rewrite-with-nginx

On my site I am using PHP to generate images with different options for styles.

The images are requested like this: "/img/image.php?user=NAME&style=STYLE"

So I have a rewrite to get the images, this is written as follows:
rewrite ^/image/([a-zA-Z0-9_+]+)/([a-zA-Z0-9+]+).png$ /img/image.php?style=$1&user=$2;

This works fine, except when my caching is uncommented in the NGINX config, it stops me from accessing the images from the rewrite. I am still able to access them without the rewrite though. Its a necessity that I have the '.png' on the end of the rewrite also.

Here is my cache setup:
location ~* \.(jpg|jpeg|png|gif|ico|css|xml|js|woff)$ {
expires 720h;
root /home/site/public;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}

Any information on how to fix this would be highly appreciated.

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>