Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I turn off caching in HTTP redirections in Node.js?

Tags:

node.js

I use node-formidable to process a form via POST at http://127.0.0.1/upload. After processing, I want to redirect the user to http://127.0.0.1/. Currently, I need to reload http://127.0.0.1/ in order to see the uploaded data. I assume I need to tweak a cache setting.

How can I do this in Node.js? Do I set Cache-Control: no-cache on http://127.0.0.1/ or /upload?

like image 488
royco Avatar asked Dec 22 '22 02:12

royco


1 Answers

you set it on http://127.0.0.1.

try something like this:

res.header('Cache-Control', 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0');
like image 171
Philipp Kyeck Avatar answered Dec 24 '22 00:12

Philipp Kyeck