Foros de discusión

Disabling browser caching while using browser back button

Ravi N, modificado hace 15 años.

Disabling browser caching while using browser back button

New Member Mensajes: 19 Fecha de incorporación: 27/11/07 Mensajes recientes
Hi,

I developed portlets in liferay extension environment. I am navigating to different portlets. But when i use browser back button, the page is getting displayed from browser cache. How to avoid getting from cache?

I tried by setting met tags Cahce-control to no-store, no-cache etc, but didn't find the result required and I set expiration-cache to 0 in portlet.xml but not useful.

Is there any way to avoid browser caching for a portlet?

If so is same thing applies to plugin portlets also

Thanks,
Ravi
Andrea Quintavalle, modificado hace 14 años.

RE: Disabling browser caching while using browser back button

New Member Mensajes: 9 Fecha de incorporación: 12/01/10 Mensajes recientes
Same problem for me.... I can't find any info on how to disable cache on a single page.
I hope after more than 1 year after previous post we'll get an answer!
thumbnail
Olaf Kock, modificado hace 14 años.

RE: Disabling browser caching while using browser back button

Liferay Legend Mensajes: 6403 Fecha de incorporación: 23/09/08 Mensajes recientes
As the browser is not caching one portlet but a whole page, it all depends...

All pages (as you never know when the back button will be used) would have to be uncached. And even with this I have the feeling that browsers might ignore it in the case of going "back". I'm never sure if such a solution "works for me (TM)" or "works always". I've seen too much browser weirdness...

Another possibility is to render relatively static code that displays a placeholder and load/display the rest via ajax. Depends on javascript though, but would solve the problem - especially if you already depend on javascript to work. The ajax request would be another http request just for your portlet and have its own caching headers that you can control better than any portlet content embedded in a bigger page.

Of course, you can have both worlds: Render the full content (risking it to be out of date) and update via ajax - that would always render your content twice though. Decide if you want to pay the price.
Jason Chen, modificado hace 13 años.

RE: Disabling browser caching while using browser back button

Junior Member Mensajes: 62 Fecha de incorporación: 22/07/10 Mensajes recientes
I had the same issue and we never want the page to be cached.
What I did was to overrdie the struts-config with:
<controller processorClass="com.liferay.portal.struts.PortalRequestProcessor" contentType="text/html; charset=UTF-8" nocache="true"/>