Playframework 2.x - prevent assets caching
-
14-12-2019 - |
Question
I'm using playframework v2 and I have my sitemap files being re-created once a day by an external process. They're all in the assets folder/sitemap
How do I force playframework to return the file directly from disk?
Solution
You should get the file (from disk or WS) and render the content in a classic Action, then set the cache with an annotation :
@Cached(key="sitemap", duration=86400)
public static Result index() {
// ... set sitemap variable from your file
return ok(siteMap);
}
http://www.playframework.org/documentation/2.0/JavaCache
Or you can achieve the same behavior with a job.
OTHER TIPS
put it in the /public folder.. resources from there are not intercepted/processed by any controller, etc.
so if you put your file into the folder /public/sitemaps/sitemap.xml it will be available as yoursite.com/public/sitemaps/sitemap.xml
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow