I am completely new to Node.js and trying to figure out a few things. Originally I was using apache and in the .htaccess I used mod_expires.c
to cache data. For instance I would do:
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
I also set up mod_rewrite.c
for cachebusting, so whenever I needed to update my css or javascript I could simply change the version in the html and the request would be routed to the regular file.
How can I implement these features in Node.js. I am currently using the Express module as well.
express.static
(which is just an exposed version of connect.static
so the documentation can be found under connect) with a maxAge
parameter should do most or all of what you want. Also look into express.staticCache
(again, alias for connect.staticCache
).