# Only html file no-cache

**URL:** <https://www.ruby-forum.com/t/only-html-file-no-cache/215266>\
**Category:** NGINX\
**Created:** [December 28, 2011, 7:50pm UTC](https://www.ruby-forum.com/t/only-html-file-no-cache/215266 "2011-12-28T19:50:19Z")\
**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:** [December 28, 2011, 7:50pm UTC](https://www.ruby-forum.com/t/only-html-file-no-cache/215266/1 "2011-12-28T19:50:19Z")

</div>

hi; my use reverse proxy and html files to be read by nginx, but I just  
want to have onyl html files no-cache …

my v\_hosts.conf  
server {  
error\_log /var/log/nginx/vhost-error\_log warn;  
listen 46.4.103.194:80;  
server\_name [skystar-2.com](http://skystar-2.com) [dvbking.com](http://dvbking.com) [www.dvbking.com](http://www.dvbking.com)  
[www.skystar-2.com](http://www.skystar-2.com);  
access\_log /usr/local/apache/domlogs/skystar-2.com-bytes\_log  
bytes\_log;  
access\_log /usr/local/apache/domlogs/skystar-2.com combined;  
root /home/skystar2/public\_html;  
error\_page 404 /404.shtml;  
error\_page 403 /403.shtml;  
error\_page 502 503 504 /50x.html;  
location / {  
location  
~._.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|txt|js|css|html|htm|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso)$  
{  
expires 7d;  
try\_files $uri @backend;  
}  
error\_page 405 = @backend;  
add\_header X-Cache “HIT from Backend”;  
proxy\_pass [http://46.4.103.194:8081](http://46.4.103.194:8081);  
include proxy.inc;  
}  
location @backend {  
internal;  
proxy\_pass [http://46.4.103.194:8081](http://46.4.103.194:8081);  
include proxy.inc;  
}  
location ~ ._.(php|jsp|cgi|pl|py)?$ {  
proxy\_pass [http://46.4.103.194:8081](http://46.4.103.194:8081);  
include proxy.inc;  
}  
location ~ /.ht {  
deny all;  
}  
}

my nginx.conf

user nobody;

# no need for more workers in the proxy mode

worker\_processes 2;  
error\_log /var/log/nginx/error.log info;  
worker\_rlimit\_nofile 20480;  
events {  
worker\_connections 5120; # increase for busier servers  
use epoll; # you should use epoll here for Linux kernels 2.6.x  
}  
http {  
server\_name\_in\_redirect off;  
server\_names\_hash\_max\_size 10240;  
server\_names\_hash\_bucket\_size 1024;  
include mime.types;  
default\_type application/octet-stream;  
server\_tokens off;  
sendfile on;  
tcp\_nopush on;  
tcp\_nodelay on;  
keepalive\_timeout 5;  
gzip on;  
gzip\_vary on;  
gzip\_disable “MSIE [1-6].”;  
gzip\_proxied any;  
gzip\_http\_version 1.1;  
gzip\_min\_length 1000;  
gzip\_comp\_level 2;  
gzip\_buffers 16 8k;

# You can remove image/png image/x-icon image/gif image/jpeg if you have

slowCPU  
gzip\_types text/plain text/html text/htm text/xml text/css  
application/x-javascript application/xml application/xml+rss  
text/javascript application/atom+xml;  
ignore\_invalid\_headers on;  
client\_header\_timeout 3m;  
client\_body\_timeout 3m;  
send\_timeout 3m;  
reset\_timedout\_connection on;  
connection\_pool\_size 256;  
client\_header\_buffer\_size 256k;  
large\_client\_header\_buffers 4 256k;  
client\_max\_body\_size 200M;  
client\_body\_buffer\_size 128k;  
request\_pool\_size 32k;  
output\_buffers 4 32k;  
postpone\_output 1460;  
proxy\_temp\_path /tmp/nginx\_proxy/;  
client\_body\_in\_file\_only on;  
log\_format bytes\_log “$msec $bytes\_sent .”;  
include “/etc/nginx/vhosts/\*”;  
}

Posted at Nginx Forum:

> **[only html file no-cache](https://forum.nginx.org/read.php?2,220621,220621#msg-220621)**
>
> hi; my use reverse proxy and html files to be read by nginx, but I just want to have onyl html files no-cache .. my v\_hosts.conf server { error\_log /var/log/nginx/vhost-error\_log warn; listen 46.4.103.194:80; server\_name skysta

---

<div class="post-metadata">

**Author:** ![codetr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/71c47a/32.png) [@codetr](https://www.ruby-forum.com/u/codetr)\
**Post date:** [December 28, 2011, 11:07pm UTC](https://www.ruby-forum.com/t/only-html-file-no-cache/215266/2 "2011-12-28T23:07:32Z")

</div>

Do not have somebody to help me

Posted at Nginx Forum:

> **[Re: only html file no-cache](https://forum.nginx.org/read.php?2,220621,220632#msg-220632)**
>
> hi; my use reverse proxy and html files to be read by nginx, but I just want to have onyl html files no-cache .. my v\_hosts.conf server { error\_log /var/log/nginx/vhost-error\_log warn; listen 46.4.103.194:80; server\_name skysta

---

<div class="post-metadata">

**Author:** ![codetr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/71c47a/32.png) [@codetr](https://www.ruby-forum.com/u/codetr)\
**Post date:** [December 29, 2011, 1:42pm UTC](https://www.ruby-forum.com/t/only-html-file-no-cache/215266/3 "2011-12-29T13:42:14Z")

</div>

solved  
location  
~._.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|txt|js|css|html|htm|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso)$  
{  
expires 7d;  
try\_files $uri @backend;  
}  
location ~._.(html|htm)$ {  
add\_header Pragma “no-cache”;  
try\_files $uri @backend;  
}

Posted at Nginx Forum:

> **[Re: only html file no-cache](https://forum.nginx.org/read.php?2,220621,220662#msg-220662)**
>
> hi; my use reverse proxy and html files to be read by nginx, but I just want to have onyl html files no-cache .. my v\_hosts.conf server { error\_log /var/log/nginx/vhost-error\_log warn; listen 46.4.103.194:80; server\_name skysta

---

<div class="post-metadata">

**Author:** ![codetr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/71c47a/32.png) [@codetr](https://www.ruby-forum.com/u/codetr)\
**Post date:** [December 31, 2011, 2:27pm UTC](https://www.ruby-forum.com/t/only-html-file-no-cache/215266/4 "2011-12-31T14:27:18Z")

</div>

Try this shorter form:

location / {  
location ~ .(html|htm)$ {  
# “pragma” is not a valid header here  
add\_header Cache-Control “no-cache, no-store”;  
try\_files $uri @backend;  
}  
expires 7d;  
try\_files $uri @backend;  
}
