# Set cache expiration based on request filename

**URL:** <https://www.ruby-forum.com/t/set-cache-expiration-based-on-request-filename/218436>\
**Category:** NGINX\
**Created:** [March 31, 2012, 5:52pm UTC](https://www.ruby-forum.com/t/set-cache-expiration-based-on-request-filename/218436 "2012-03-31T17:52:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [March 31, 2012, 5:52pm UTC](https://www.ruby-forum.com/t/set-cache-expiration-based-on-request-filename/218436/1 "2012-03-31T17:52:53Z")

</div>

Hey folks,

My Django website uses a subdomain to serve static content and as such I  
have ‘expires’ set to max. However, there is now one image on that  
domain  
that get’s re-generated every 10 minutes. How would I go about forcing  
just  
that one filename to NOT be cached by the browser?

This is what I have:

server {  
listen 80;  
listen 443;  
ssl on;  
server\_name [static.example.com](http://static.example.com);  
expires max;  
add\_header Cache-Control public;  
access\_log off;  
root /home/username/public\_html/static.example.com/;  
}

---

<div class="post-metadata">

**Author:** ![micahphone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/2bfe46/32.png) [@micahphone](https://www.ruby-forum.com/u/micahphone)\
**Post date:** [March 31, 2012, 5:57pm UTC](https://www.ruby-forum.com/t/set-cache-expiration-based-on-request-filename/218436/2 "2012-03-31T17:57:14Z")

</div>

I think you want to use “location” directive, and an expires inside 😉

–  
Cordialement, Adnan RIHAN.  
Président-Fondateur de l’association Virtual-Info (Loi 1901),  
hébergement Web et Serveurs de jeux.  
Technicien-Supérieur développeur d’applications Web et Système.  
3e année à {Epitech}.  
Envoyé de mon iPhone 

Le 31 mars 2012 à 17:52, Micah C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) a écrit :

Hey folks,

My Django website uses a subdomain to serve static content and as such I  
have ‘expires’ set to max. However, there is now one image on that  
domain  
that get’s re-generated every 10 minutes. How would I go about forcing  
just  
that one filename to NOT be cached by the browser?

This is what I have:

server {  
listen 80;  
listen 443;  
ssl on;  
server\_name [static.example.com](http://static.example.com);  
expires max;  
add\_header Cache-Control public;  
access\_log off;  
root /home/username/public\_html/static.example.com/;  
}

---

<div class="post-metadata">

**Author:** ![micahphone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/2bfe46/32.png) [@micahphone](https://www.ruby-forum.com/u/micahphone)\
**Post date:** [March 31, 2012, 6:28pm UTC](https://www.ruby-forum.com/t/set-cache-expiration-based-on-request-filename/218436/3 "2012-03-31T18:28:48Z")

</div>

Boy do I feel foolish. Of course. Thanks!

---

<div class="post-metadata">

**Author:** ![micahphone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/2bfe46/32.png) [@micahphone](https://www.ruby-forum.com/u/micahphone)\
**Post date:** [March 31, 2012, 10:22pm UTC](https://www.ruby-forum.com/t/set-cache-expiration-based-on-request-filename/218436/4 "2012-03-31T22:22:22Z")

</div>

Sent from my BlackBerry device on the Rogers Wireless Network
