Skip to content

Commit dc225a5

Browse files
authored
www/nginx: Add basic support for forced caching (#4481)
1 parent e2aa9e1 commit dc225a5

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/forms/location.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@
9696
<advanced>true</advanced>
9797
<help>Enter how often the resource must be hit before adding it to the cache.</help>
9898
</field>
99+
<field>
100+
<id>location.cache_valid</id>
101+
<label>Cache: Force caching time</label>
102+
<type>text</type>
103+
<advanced>true</advanced>
104+
<help>Force caching of 200, 301 and 302 responses according to the request methods enabled for caching. Given in minutes; leave empty to rely on request/response headers from client and upstream.</help>
105+
</field>
99106
<field>
100107
<id>location.cache_background_update</id>
101108
<label>Cache: Background Update</label>

www/nginx/src/opnsense/mvc/app/models/OPNsense/Nginx/Nginx.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,9 @@
349349
<Required>Y</Required>
350350
<default>1</default>
351351
</cache_min_uses>
352+
<cache_valid type="IntegerField">
353+
<Required>N</Required>
354+
</cache_valid>
352355
<cache_background_update type="BooleanField">
353356
<Required>Y</Required>
354357
<default>0</default>

www/nginx/src/opnsense/service/templates/OPNsense/Nginx/location.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ location {{ location.matchtype }} {{ location.urlpattern }} {
142142
proxy_cache {{ location.cache_path.replace('-', '') }};
143143
{% if location.cache_use_stale is defined and location.cache_use_stale != '' %}
144144
proxy_cache_use_stale {{ location.cache_use_stale.replace(',', ' ') }};
145+
{% endif %}
146+
{% if location.cache_valid is defined and location.cache_valid != '' %}
147+
proxy_cache_valid {{ location.cache_valid }}m;
145148
{% endif %}
146149
proxy_cache_min_uses {{ location.cache_min_uses|default('1') }};
147150
proxy_cache_background_update {% if location.cache_background_update is defined and location.cache_background_update == '1' %}on{% else %}off{% endif %};

0 commit comments

Comments
 (0)