I am trying to cache some results of a js script. (note this is working for other things like raw string data returned from a service, just not for this. Also note this is the first time I am trying to do it with a script and .js file.
Working: in html:
<script src="https://www.notmydomain.com/script.js?param1=blah"></script>
not working: in html:
<script src="/script.js?param1=blah"></script>
in @RestConroller method (from System.out.println's I know its returning the exact same thing as when I call the script directly):
@GetMapping("/script.js")
public String script(Model model, @RequestParam Map<String,String> allRequestParams) {
String parameters = inputParameterBuilder.buildParametersString(allRequestParams);
String js = pagesCacheService.getPage("script.js"+parameters, null, String.class);
if(null == js) {
js = resttemplate.getForObject("https://www.notmydomain.com/script.js" + parameters, String.class);
pagesCacheService.updatePage("script.js"+parameters, js, String.class);
}
return js;
}
Thanks, Brian
Solved the issue: @GetMapping(value = "/script.js",produces = "text/javascript")