don't cache dynamiclocation results

This commit is contained in:
Laura Klünder 2023-11-24 17:24:07 +01:00
parent 550d77f774
commit f7a4055c1c
3 changed files with 9 additions and 3 deletions

View file

@ -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

View file

@ -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),