Reputation: 4044
I'm working on a jsf project, and I have several xhtml pages which use the same template. The template contains the layout and the page header. I would like to know if it is possible to not reload the header when user navigates to another page, since it is always the same; and as it contains a couple of images it makes navigating unnecessarily slower.
One remark: I'm using a filter that adds the following headers to the response, for security reasons:
HttpServletResponse resp = (HttpServletResponse) response;
resp.setHeader("Cache-Control", "no-cache,no-store,must-revalidate"); // HTTP 1.1
resp.setHeader("Pragma", "no-cache"); // HTTP 1.0
resp.setDateHeader("Expires", 0); // Proxies.
Can it be done without removing those headers?
Thanks! Damian
Upvotes: 1
Views: 1709
Reputation: 691
Looking for a similar technique in my audio player to don't stop listenig during navigation. I just look at soundcloud site. U can refresh content in ajax and change url in javascript with window.history.pushState look here:
http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#dom-history-pushstate
It probably doesn't work with old browser...
Upvotes: 0
Reputation: 1108722
The template contains the layout and the page header. I would like to know if it is possible to not reload the header when user navigates to another page, since it is always the same;
This is only possible when using a HTML frame (not recommended) or when refreshing the page parts by Ajax requests instead of normal requests. However, the disadvantage is that you end up with unbookmarkable URLs.
and as it contains a couple of images it makes navigating unnecessarily slower.
If that is the real problem, then you need to instruct the browser to actually cache the images (and CSS and JS). So if you're setting those response headers on image/CSS/JS requests as well, then the browser is forced to reload them everytime. This is unnecessary and will indeed result in slow loading. You need to ensure that those headers are only set on JSF pages, so you need to ensure that the URL pattern of the filter matches JSF page requests only, e.g. *.jsf
or *.xhtml
and thus not /*
or something.
Upvotes: 1