Friday, January 1, 2016

Application.js and Application.css not being cached by my browser

I was recently troubleshooting an issue with an application I'm building.  I'm using Apache 2.x,  Rails 4.x and after properly configuring the asset pipeline for my staging environment to use pre-complied assets and allowing Apache to serve those assets the application.js and application.css files were not being cached by Chrome.   At first I thought this was an issue with Rails but quickly tailing the log file indicated that Rails wasn't involved with the assets and this was something on the Apache or browser end.  I suspected Apache so I reviewed my configuration but everything seemed just fine. That's when I stumbled across this post on Chrome not caching files if HTTPS is used...   It turns out that I am indeed using a self signed certificate in my stage environment and my application enforces SSL so that's why these files were not cached by the browser.  Maybe this should have been obvious to me but I did spin for a couple hours on this so because of that I thought this post was in order to hopefully save someone else the same effort.   Basically, if your using self signed certificates you should expect Chrome to cache your assets.