I searched a lot about the subject and why/how to avoid restfull api caching, butI didn't get a helpful answer.
I built expressjs api to generate random json data using faker module everything went fine for the first request but any refresh on the browser or any additional requests display the same data.
I want with every request generate a random data but I think after the first request the nodejs module is cached.
I'm using
nodejs: the latest version, expressjs: v4.0, faker: the latest
my code as below:
in the router file: router.js
var router = express.Router();
router.get('/name', controller.name);
.
.
in the controller file: json.controller.js
//Get name
var name = require('name.model.js');
exports.name = function(req, res){
var randomName = name;
return res.json(200, randomName);
};
in the model file: name.model.js
var faker = require('faker');
var nameModel = {};
nameModel.name = faker.name.findName();
module.exports = nameModel;
Can any one help how to avoid rest api caching? and how to fix it in my case?
Thanx for any help,