How to cache portal page in browser/proxy

WebSphere Portal allows you to configure a page so that it can be cached by user's browser or the proxy server. It does that by setting the appropriate values for Cache-control and Expires header.

I wanted to try this feature and see if i can configure a page to be cached for 1 day (i.e. 86400 seconds). In order to do that i had to configure WebSphere Portal so that it sets cache-control: max-age=86400. Also since i want the page to be cached across users, so this is how my cache-control header should look like Cache-Control public, max-age=86400


  • First find out what all portlets are going to be displayed on the page that you want to cache, for each of those portlets set expirate-cache and public-scope header. In my case i have only one RemoteCachePortlet on the page so i configured it like this

    <?xml version="1.0" encoding="UTF-8"?>
    <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
    version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd
    http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
    <portlet>

    <portlet-name>RemoteCachePortlet</portlet-name>
    <display-name>Remote Cache Portlet</display-name>
    <portlet-class>com.webspherenotes.performance.RemoteCachePortlet</portlet-class>
    <expiration-cache>86400</expiration-cache>
    <cache-scope>public</cache-scope>

    <supports>
    <mime-type>text/html</mime-type>
    <portlet-mode>view</portlet-mode>
    </supports>

    <portlet-info>
    <title>Remote Cache Portlet</title>
    <short-title>Remote Cache Portlet</short-title>
    <keywords>Remote Cache Portlet</keywords>
    </portlet-info>

    </portlet>

    </portlet-app>


  • Next create a page and configure the Page Cache Options like this


  • Last step would be to add two set these two properties at the Navigation Service like this




Once the page is configured try accessing the page and you should see the headers being set like this




You can see that Cache-control header is being set and now if you look for the cache-entry in the browser you will notice that page is supposed to get expired in 24 hrs from the time you accessed it




Important Note The headers returned by portal server look ok but when i tried it on local somehow the IE browser is making request to the server. But the Google's Chrome browser is not it is able to deal with cache properly. Not sure if something else is causing this

1 comment:

nDarkDuck said...

Unfortunatelly public.session=true sets public cache automatically to private. :(