Home > ApEx > How to stop your Apex pages being cached

How to stop your Apex pages being cached

Why Browser Caching is Good

Browser caching is often a very useful thing. Accessing a web site you visit often, it can greatly speed things up if much of the contents can be read from your local browser’s cache rather than having to be re-fetched from the server.

Why Browser Caching is Bad

Sometimes, however, caching is not what you want. For example, you may have data which is displayed in the course of a user using your application which you would not want to be cached because you would not want that potentially sensitive information to be stored locally or accessible to other users (simply clicking Back in a browser will often display a cached version of the page). In the scenario where you have logged into an application, viewed some sensitive information, clicked Log Out but left the Browser window open, another user who sits down at the same computer may well be able to click "Back" in their browser to look at what you were just looking at (even though they will not be able to interact with the application in any way because they are not logged in).

How to Stop Caching

There are meta-tags (e.g. <meta http-equiv="Pragma" content="no-cache"/>) which you can specify in the HTML of your web pages whose raison d’etre would seem to be to prevent caching. However, as this Microsft article indicates, these, in fact, have no effect in Internet Explorer 6 (or 7 or 8). One alternative solution that this article suggests is to use SSL / HTTPS. This would indeed work but what if you don’t want to use HTTPS? The other choice is to set HTTP headers to instruct the browser not to cache.

How to Set HTTP Headers to Stop Caching

If using OHS (Oracle HTTP Server, i.e. Apache) you can modify your httpd.conf file to set such headers for only certain URLs so that, for example, your Apex pages are never cached. You would need to add something similar to the following to your httpd.conf file (found in %ORACLE_HOME%\Apache\Apache\conf\httpd.conf):

<LocationMatch "/pls/apex/f">
<IfModule mod_headers.c>
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"

You would need to modify the "/pls/apex/f" value if your DAD is something other than the default of "/pls/apex". The above entry will have the effect of preventing caching for all of your Apex pages accessed via this DAD (including those pages associated with Application Builder). You can add in this text pretty much anywhere in your httpd.conf file as long as it is after the call to "AddModule mod_headers.c", Once you have made the change you will need to restart Apache (by running, for example, %ORACLE_HOME%\opmn\bin\opmnctl restartproc ias-component=HTTP_Server from a Command Prompt).

This works in Internet Explorer 6, 7 and 8 as well as in Firefox.

Categories: ApEx
  1. March 13, 2009 at 1:06 pm


    I experienced some cache problems with updateable reports and IE6. It just saved some cache information and showed wrong values after a application based page reload. The same thing did not happened in Firefox and IE7. After clearing the cache in IE6 and set up some configuration inside IE6 the error didn’t occurred again.



  2. March 13, 2009 at 11:22 am

    Hi Andy,

    I had some issues whith cache problems especially with IE6. I implemented your solution and it seems like all values get saved inside the page even when an application validation error occurs.



  3. Andrew Tulley
    March 13, 2009 at 12:00 pm


    What exactly is the problem you are experiencing? What would you like to see happening that isn’t?

    The modification to the Apache httpd.conf will stop IE caching, it will not modify Apex behaviour in any way. Apex will still save content in session state in exactly the same way, regardless whether you have added this entry into httpd.conf or not.


  4. February 2, 2009 at 2:50 pm

    Good post!

    That’s an interesting question Patrick is asking.


  5. February 2, 2009 at 9:33 am

    Hi Andy,

    what effect does this change have on the entered data of a tabular form when the separate error page is displayed? I assume it will discard the entered data because the browser will reload the tabular form page as soon as the user clicks the “OK” link (which is a browser back)… Can’t test it myself because I currently have limited access to an application server where I could do some testing.


  6. Andrew Tulley
    February 2, 2009 at 2:58 pm


    Though I haven’t had chance to test it yet, I suspect you are absolutely right. Calling history.go(-1) will be exactly the same as clicking Back in your browser (i.e. the page will be reloaded).


  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: