equal
deleted
inserted
replaced
13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
14 # details. |
14 # details. |
15 # |
15 # |
16 # You should have received a copy of the GNU Lesser General Public License along |
16 # You should have received a copy of the GNU Lesser General Public License along |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 """HTTP cache managers |
18 """HTTP cache managers""" |
19 |
19 |
20 |
|
21 """ |
|
22 __docformat__ = "restructuredtext en" |
20 __docformat__ = "restructuredtext en" |
23 |
21 |
24 from time import mktime |
22 from time import mktime |
25 from datetime import datetime |
23 from datetime import datetime |
26 |
24 |
54 * set policy to 'must-revalidate' and expires to the current time to force |
52 * set policy to 'must-revalidate' and expires to the current time to force |
55 revalidation on each request |
53 revalidation on each request |
56 """ |
54 """ |
57 |
55 |
58 def etag(self): |
56 def etag(self): |
|
57 if not self.req.cnx: # session without established connection to the repo |
|
58 return self.view.__regid__ |
59 return self.view.__regid__ + '/' + ','.join(sorted(self.req.user.groups)) |
59 return self.view.__regid__ + '/' + ','.join(sorted(self.req.user.groups)) |
60 |
60 |
61 def max_age(self): |
61 def max_age(self): |
62 # 0 to actually force revalidation |
62 # 0 to actually force revalidation |
63 return 0 |
63 return 0 |
142 # configure default caching |
142 # configure default caching |
143 viewmod.View.http_cache_manager = NoHTTPCacheManager |
143 viewmod.View.http_cache_manager = NoHTTPCacheManager |
144 # max-age=0 to actually force revalidation when needed |
144 # max-age=0 to actually force revalidation when needed |
145 viewmod.View.cache_max_age = 0 |
145 viewmod.View.cache_max_age = 0 |
146 |
146 |
147 |
|
148 viewmod.EntityView.http_cache_manager = EntityHTTPCacheManager |
|
149 |
|
150 viewmod.StartupView.http_cache_manager = MaxAgeHTTPCacheManager |
147 viewmod.StartupView.http_cache_manager = MaxAgeHTTPCacheManager |
151 viewmod.StartupView.cache_max_age = 60*60*2 # stay in http cache for 2 hours by default |
148 viewmod.StartupView.cache_max_age = 60*60*2 # stay in http cache for 2 hours by default |