I have a Flask application for which I have applied successfully caching. However now I need to also send the response in compress mode if and only if the header 'accept-encoding = gzip' is present. Otherwise just sent plain JSON. I am using this example to compress the response. In this case only the JSON is cached. I would like to have both cached. But since Flask-Caching only caches data by using parameters and ignore headers (AFAIK) I am no sure if there is a way to generate two different cache entries using headers also. Each of the two possible Mime type responses (JSON and Zip JSON) should have an entry in the cache. Once is cached the responses to the largest payload (1.41MB) takes 7ms (JSON) and 38ms (JSON-ZIP). So there is a 31 milliseconds to be shaved off if I could cache by header also.
flask== 2.2.2
Flask-Caching==2.0.2