Reputation: 692
In this sailsjs app we are not using any database. There is multiple json files in folder in data folder ( you can see it in root level). Inside controller we are accessing like
req.session.categories = require(require('path').resolve('data/catInfo.json'));
catInfo.json is updated through some cron job twice a day. Issue is sailsjs not picking up updated data but if i restart the server then it is picking up new data. somewhere it is storing old json and serve that old json.
What i had already checked :
1. try new browser / incognito browser. so this is not a session issue.
2. data folder is not under assets folder. so it is not going under .tmp folder.
Then where the old data is being stored ?
Upvotes: 0
Views: 71
Reputation: 32117
Modules included with require
are cached, that means JSON files too.
If the file is being updated then you'll need to read it using the fs
module.
req.session.categories =
JSON.parse(
require('fs').readFileSync(require('path').resolve('data/catInfo.json'))
);
Upvotes: 1