I've implemented this solution to help prevent browser page caching, based on the question How to prevent browser page caching in Rails:
def set_cache_buster
response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
response.headers["Pragma"] = "no-cache"
response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
end
While this certainly work, it feels a bit like killing an ant with a sledgehammer; everything is prevent from caching, including images (e.g., a hamburger icon, or other small images like that). When navigating from page to page, this results in unsightly flashes of empty content while these images are reloaded.
Is there a way that I can prevent general caching, but exempt certain assets?