# Nginx cache bypass

**URL:** <https://forum.hestiacp.com/t/nginx-cache-bypass/1338>\
**Category:** Web\
**Created:** [July 20, 2020, 10:43pm UTC](https://forum.hestiacp.com/t/nginx-cache-bypass/1338 "2020-07-20T22:43:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![djav1985](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/djav1985/32/3021_2.png) [@djav1985](https://forum.hestiacp.com/u/djav1985)\
**Post date:** [July 20, 2020, 10:43pm UTC](https://forum.hestiacp.com/t/nginx-cache-bypass/1338/1 "2020-07-20T22:43:25Z")

</div>

Is the $no\_cache variable and wp cooke and session section of the nginx.conf not set up fully? On a default install they don’t do anything, and looking in the confs it doesn’t look like everything needed is there?

Also I can’t seem to override this part of the conf for /wp-admin/ Like nothing has worked…

location / {  
proxy\_pass [https://xxxxxxxx](https://xxxxxxxx)  
location ~\* ^.+.(webp|jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|ttf|otf|woff|woff2|json|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mpeg|mpg|wmv|exe|iso|dmg|swf|css|exe|pdf|doc|xls|ppt|txt|odt|ods|odp|odf|tar|bmp|rtf|js|mp3|avi|mpeg|flv|html|htm)$ {  
root /home/xxxxxxxxxxx/public\_html;  
access\_log /var/log/apache2/domains/xxxxxxxxxlog combined;  
access\_log /var/log/apache2/domains/xxxxxxxm.bytes bytes;  
expires max;  
try\_files $uri @fallback;  
}  
}

---

<div class="post-metadata">

**Author:** ![eris](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/eris/32/1241_2.png) [@eris](https://forum.hestiacp.com/u/eris)\
**Post date:** [July 20, 2020, 11:03pm UTC](https://forum.hestiacp.com/t/nginx-cache-bypass/1338/2 "2020-07-20T23:03:11Z")

</div>

Currently I am using the following template the cacheing template found in /usr/local/hestia/data/templates/web/nginx/

For me it works fine on a heavy wordpress site.

The no cache part:

```
location / {
    proxy_pass http://%ip%:%web_port%;

    proxy_cache cache;
    proxy_cache_valid 15m;
    proxy_cache_valid 404 1m;
    proxy_no_cache $no_cache;
    proxy_cache_bypass $no_cache;
    proxy_cache_bypass $cookie_session $http_x_update;

    location ~* ^.+\.(%proxy_extentions%)$ {
        proxy_cache off;
        root %docroot%;
        access_log /var/log/%web_system%/domains/%domain%.log combined;
        access_log /var/log/%web_system%/domains/%domain%.bytes bytes;
        expires 1h;
        try_files $uri @fallback;
    }
}
```

---

<div class="post-metadata">

**Author:** ![djav1985](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/djav1985/32/3021_2.png) [@djav1985](https://forum.hestiacp.com/u/djav1985)\
**Post date:** [July 20, 2020, 11:21pm UTC](https://forum.hestiacp.com/t/nginx-cache-bypass/1338/3 "2020-07-20T23:21:47Z")

</div>

I had to stop using the caching template cause it aggressively cached my wp admin

---

<div class="post-metadata">

**Author:** ![djav1985](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/djav1985/32/3021_2.png) [@djav1985](https://forum.hestiacp.com/u/djav1985)\
**Post date:** [July 21, 2020, 12:10am UTC](https://forum.hestiacp.com/t/nginx-cache-bypass/1338/4 "2020-07-21T00:10:36Z")

</div>

that block is setting cache control headers for a year on wordpress admin. I tried to override it but i can only get the page not the assets to change

---

<div class="post-metadata">

**Author:** ![eris](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/eris/32/1241_2.png) [@eris](https://forum.hestiacp.com/u/eris)\
**Post date:** [July 21, 2020, 5:47am UTC](https://forum.hestiacp.com/t/nginx-cache-bypass/1338/5 "2020-07-21T05:47:22Z")

</div>

Assets are not chanced due to the log expires time.

Decrease it to zero or maybe 5min. How ever it would be better if Hestia could support [https://github.com/FRiCKLE/ngx\_cache\_purge](https://github.com/FRiCKLE/ngx_cache_purge)

---

<div class="post-metadata">

**Author:** ![djav1985](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/djav1985/32/3021_2.png) [@djav1985](https://forum.hestiacp.com/u/djav1985)\
**Post date:** [July 21, 2020, 7:58am UTC](https://forum.hestiacp.com/t/nginx-cache-bypass/1338/6 "2020-07-21T07:58:31Z")

</div>

That is “Mod\_Expires” equivalent. It may be under the log directory line but it is not an expires setting for logs. It sets the may time on cache control headers.
