I have been struggling with a problem to manage and control cache for my one page application with multiple internal routing. I have used yeoman as a scaffolding tool for my application & Heroku is my server. I want to enable cache for images, java script, and html of my application, but if I make some changes in any of my files it should automatically reflect when the end user requests the page on that route again rather than rendering a cached copy of that page. I wrote a code in my web.js as:
This code stops all the caching of the application in any browser. But this affects my website's speed as each request from the end user renders all data(images, HTML, JS) from the server weather it is modified or not. I have internal routing in my application's app.js file which renders various pages on different URL request as follows:
So what should I code for enabling caching for my application which should render a fresh copy of a modified file and cached copy of the unmodified files and images. Thanks. |