掲示板

Disable browser cache in porltet jsp page

thumbnail
8年前 に Sandip Patel によって更新されました。

Disable browser cache in porltet jsp page

Regular Member 投稿: 205 参加年月日: 11/01/05 最新の投稿
Hi,

I want to disable browser cache in my one of the jsp page. So I have add below lines in my portlet jsp page.

<liferay-util:html-top>
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
</liferay-util:html-top>

This code help me to add meta tag in <head> part but My browser page is cached when I click on browser back button.
I can see below lines in one of the forum this forum page : https://www.liferay.com/community/forums/-/message_boards/message/21147656

"Liferay does not use HTTP Caching for portlet-type pages, it does not reply with Last-Modified, ETag, Cache-Control, Expires HTTP headers
(except for JavaScript files etc.). "

Can Anyone help me How to disable browser cache in one of the liferay portlet jsp page.
8年前 に saifulla soudagar によって更新されました。

RE: Disable browser cache in porltet jsp page

New Member 投稿: 9 参加年月日: 14/08/04 最新の投稿
Hi Sandeep,

To disable browser cache add the following line to your portal-ext.propeties file


"browser.cache.disabled=true"
8年前 に saifulla soudagar によって更新されました。

RE: Disable browser cache in porltet jsp page

New Member 投稿: 9 参加年月日: 14/08/04 最新の投稿
Hi sandip,

To disable browser caching for a specific JSP page add the following line in your JSP page

"
<%
response.setHeader( "Pragma", "no-cache" );
response.setHeader( "Cache-Control", "no-cache" );
response.setDateHeader( "Expires", 0 );
%>

"
thumbnail
8年前 に Olaf Kock によって更新されました。

RE: Disable browser cache in porltet jsp page

Liferay Legend 投稿: 6403 参加年月日: 08/09/23 最新の投稿
Well, this might fail miserably when the portlet is loaded by ajax, or when the response is already committed so that no more headers can be sent. You shouldn't mess up with the JSP-standard request and response objects - rather use the portletrequest and portletresponse. These don't have headers and you don't have the control that you're quoting here (response.setHeader), but they actually work.

Ever seen a "response already committed" error message? That's what you get from this kind of operation - and you can even get it in the servlet world. No guarantee that it's working and good chance that it will fail intermittently, hard to reproduce, if the application server's buffers happen to be smaller than during your development time (e.g. during high load).