flask-caching icon indicating copy to clipboard operation
flask-caching copied to clipboard

Include HTTP method in cache key

Open snarfed opened this issue 4 years ago • 0 comments

I hit a bit of a nasty surprise recently when I cached a view like this, and found that HEAD responses were being cached and returned to GET requests. We should probably include the HTTP method in the cache key by default, right?

@app.route('/foo', methods=['HEAD', 'GET'])
@cache.cached(600)
def foo():
  ...

(I know work here is on a bit of a hiatus right now due to #268! Totally ok, just filing to keep track.)

snarfed avatar Sep 02 '21 02:09 snarfed