don't cache dynamiclocation results
This commit is contained in:
parent
550d77f774
commit
f7a4055c1c
3 changed files with 9 additions and 3 deletions
|
@ -24,9 +24,11 @@ def newapi_etag(permissions=True, etag_func=AccessPermission.etag_func, base_map
|
|||
def outer_wrapped_func(request, *args, **kwargs):
|
||||
response = func(request, *args, **kwargs)
|
||||
if response.status_code == 200:
|
||||
response['ETag'] = request._target_etag
|
||||
if request._target_etag:
|
||||
response['ETag'] = request._target_etag
|
||||
response['Cache-Control'] = 'no-cache'
|
||||
request_cache.set(request._target_cache_key, response, 900)
|
||||
if request._target_cache_key:
|
||||
request_cache.set(request._target_cache_key, response, 900)
|
||||
return response
|
||||
return outer_wrapped_func
|
||||
|
||||
|
|
|
@ -94,6 +94,10 @@ def _location_retrieve(request, location, detailed: bool, geometry: bool, show_r
|
|||
if not show_redirects:
|
||||
return redirect('../' + str(location.target.slug)) # todo: use reverse, make pk and slug both work
|
||||
|
||||
if isinstance(location, (DynamicLocation, Position)):
|
||||
request._target_etag = None
|
||||
request._target_cache_key = None
|
||||
|
||||
return location.serialize(
|
||||
detailed=detailed,
|
||||
geometry=geometry and can_access_geometry(request),
|
||||
|
|
|
@ -80,7 +80,7 @@ class LocationSchema(WithAccessRestrictionSchema, TitledSchema, LocationSlugSche
|
|||
None,
|
||||
title="more data for search index, only set when looking for searchable locations"
|
||||
)
|
||||
|
||||
|
||||
|
||||
class LabelSettingsSchema(DjangoModelSchema): # todo: add titles back in here
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue