Commit b21146a8 authored by Romain Courteaud's avatar Romain Courteaud

[ERP5Type] Support 'Cache-Control: must-revalidate' in Accelerated HTTP Cache Manager

parent 26d1f5dd
No related merge requests found
......@@ -22,6 +22,10 @@
<key> <string>interval</string> </key>
<value> <int>3600</int> </value>
</item>
<item>
<key> <string>must_revalidate</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>notify_urls</string> </key>
<value>
......
......@@ -22,6 +22,10 @@
<key> <string>interval</string> </key>
<value> <int>3600</int> </value>
</item>
<item>
<key> <string>must_revalidate</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>notify_urls</string> </key>
<value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="AcceleratedHTTPCacheManager" module="Products.StandardCacheManagers.AcceleratedHTTPCacheManager"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_AcceleratedHTTPCacheManager__cacheid</string> </key>
<value> <string>139793752921944_1557734604.715313</string> </value>
</item>
<item>
<key> <string>_settings</string> </key>
<value>
<dictionary>
<item>
<key> <string>anonymous_only</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>interval</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>must_revalidate</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>notify_urls</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>public</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>stale_if_error_interval</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>stale_while_revalidate_interval</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>must_revalidate_http_cache</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
anonymous_http_cache
http_cache
must_revalidate_http_cache
user_ram_cache
\ No newline at end of file
......@@ -59,6 +59,17 @@
public> checked="checked"</dtml-if> />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Must-Revalidate?
</div>
</td>
<td align="left" valign="top">
<input type="checkbox" name="must_revalidate" value="1"<dtml-if
must_revalidate> checked="checked"</dtml-if> />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
......
......@@ -42,6 +42,8 @@ def ZCache_set(self, ob, data, view_name, keywords, mtime_func):
%(self.stale_while_revalidate_interval))
if getattr(self, 'public', 0):
cache_control_parameter.append('public')
if getattr(self, 'must_revalidate', 0):
cache_control_parameter.append('must-revalidate')
RESPONSE.setHeader('Last-Modified', rfc1123_date(time.time()))
RESPONSE.setHeader('Cache-Control', ", ".join(cache_control_parameter))
RESPONSE.setHeader('Expires', expires)
......@@ -59,6 +61,7 @@ def __init__(self, ob_id):
'stale_if_error_interval' : 300,
'stale_while_revalidate' : 10,
'public': 1,
'must_revalidate': 0,
'notify_urls': ()}
self._resetCacheId()
......@@ -73,6 +76,7 @@ def manage_editProps(self, title, settings=None, REQUEST=None):
'stale_if_error_interval' : int(settings['stale_if_error_interval']),
'stale_while_revalidate_interval' : int(settings['stale_while_revalidate_interval']),
'public': settings.get('public') and 1 or 0,
'must_revalidate': settings.get('must_revalidate') and 1 or 0,
'notify_urls': tuple(settings['notify_urls'])}
cache = self.ZCacheManager_getCache()
cache.initSettings(self._settings)
......@@ -90,6 +94,8 @@ def getSettings(self):
self._settings.update({'stale_while_revalidate_interval' : 0})
if 'public' not in self._settings:
self._settings.update({'public' : 0})
if 'must_revalidate' not in self._settings:
self._settings.update({'must_revalidate' : 0})
return self._settings.copy() # Don't let UI modify it.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment