I am trying to implement browser caching using If-Modified-Since
headers in my Flask application. During normal navigation (as in, clicking a link, rather than a hard refresh), Firefox caches the page rather than making the HTTP request. This means that Firefox is not sending the If-Modified-Since
header, and thus the server is not able to return an updated version of the page.
Attached is a screenshot of my console. Of note:
- The response is marked as "cached"
- The cached response is saying that my server is returning an If-Modified-Since header. However, it is returning the previous value of that header. If Firefox were to actually make the HTTP request, the server would return with an updated timestamp.
Is this typical behavior? Should I be using cache headers differently? How can I achieve the intended behavior, whereby the browser only caches if the server confirms that the content has not been updated? (Firefox 81.0.2 on OSX).