How do you add an Expires or a Cache-Control header in JSP? I want to add a far-future expiration date in an include page for my static components such as images, CSS and JavaScript files.
How do you add an Expires or a Cache-Control header in JSP? I want
Share
To disable browser cache for JSP pages, create a
Filterwhich is mapped on anurl-patternof*.jspand does basically the following in thedoFilter()method:This way you don’t need to copypaste this over all JSP pages and clutter them with scriptlets.
To enable browser cache for static components like CSS and JS, put them all in a common folder like
/staticor/resourcesand create aFilterwhich is mapped on anurl-patternof/static/*or/resources/*and does basically the following in thedoFilter()method:See also: