Reputation:
I have my project structured this way :
src/main/java
com.test.project
com.test.project.configuration
com.test.project.controller
com.test.project.model
com.test.project.repository
com.test.project.service
src/main/resources
static
css
js
jquery..
calculate.js
images
templates
admin
user
statistics.html
login.html
In my calculate.js file I have an ajax call to the database, and there's some values I retrieve to show in a table in the statistics.html But the thing is, once calculated those values get cached and when I call the calculate.js again for other data, the same retrieve info from the first time show again.
I tried adding this on the application.properties
spring.resources.chain.cache=false
spring.resources.chain.strategy.content.enabled=true
spring.resources.chain.strategy.content.paths=/**
But they're still there. How do I fix this ?
Edit:
this is my rest controller : @RequestMapping(value = "calculatedResults/{id}", method = RequestMethod.GET) public SurveyComparison getComparisonResultById(@PathVariable("id") long id, final HttpServletResponse response){ response.setHeader("Cache-Control", "no-cache"); return calculateService.getSurveyById(id); }
my ajax call :
function getSurveyResults(id){
var url="/calculatedResults/"+id;
requestZ=$.getJSON(url,function(data){
surveyResults=data;
});
}
getSurveyResults(surveyId);
$.when(requestZ).then(function(){
document.getElementById("score1").innerHTML=surveyResults.scored1;}
And I fill out some columns of certain id with different values
Upvotes: 0
Views: 917
Reputation: 128
Try this to stop caching of page as it works for me:
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
Upvotes: 0