7

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?

Community
  • 1
  • 1
Rob
  • 25,984
  • 32
  • 109
  • 155
  • Are you trying to solve this problem in development, or production? If the latter, what kind of production environment is it? Heroku? – Matt Brictson May 05 '15 at 04:36
  • I'm seeing the issue in development, but hadn't thought to try running in production mode and seeing what happens. Will give that a whirl. – Rob May 05 '15 at 16:49

1 Answers1

1

Sorry for miss on tags, but as i see nginx can be a perfect answer to it - just serve static content (images/css/etc) with nginx and pass all other requests to backend (ruby)

He11ion
  • 56
  • 2
  • 7