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:
app.use(function noCache(req, res, next) {
res.header("Cache-Control", "no-cache, no-store, must-revalidate");
res.header("Pragma", "no-cache");
res.header("Expires",0);
next(); });
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:
app.config(function ($routeProvider) {
$routeProvider
.when('/main', {
templateUrl: 'views/main.html',
controller: 'MainCtrl',
})
.otherwise({
redirectTo: '/main'
});});
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.
So can someone help to get me a workaround for my issue.
Thanks.
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/dd1ab4eb-6259-4c73-a857-8e97c981d42d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.