Prevent WebHelp Caching in Browser.

Having trouble installing Oxygen? Got a bug to report? Post it all here.
JeffR
Posts: 7
Joined: Thu Mar 13, 2014 4:23 pm

Prevent WebHelp Caching in Browser.

Post by JeffR »

Hey folks,

Is there a way to prevent browsers from caching webhelp?

I had a situation where someone requested a change to topic content and could not see the updates until they refreshed the browser. Easy fix in this instance, but I want to eliminate the possibility of my readers using stale cached content when updates are available.

Thanks!!
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Prevent WebHelp Caching in Browser.

Post by sorin_ristache »

Hello,

You can add meta instructions in every Webhelp page that disables the browser cache policy. It seems the following two header instructions added in a web page disables the cache policy in recent versions of all browsers:

Code: Select all

    <meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
You should add these two lines:
  • in the "jsAndCSS" template from file:

    [Oxygen-install-dir]\frameworks\dita\DITA-OT\plugins\com.oxygenxml.webhelp\xsl\dita\desktop\common.xsl

    following the line:

    Code: Select all

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  • in the "create-toc-common-file" template from file:

    [Oxygen-install-dir]\frameworks\dita\DITA-OT\plugins\com.oxygenxml.webhelp\xsl\createMainFiles.xsl

    following the lines:

    Code: Select all

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>

Regards,
Sorin
kirkilj
Posts: 110
Joined: Fri May 14, 2010 12:14 am

Re: Prevent WebHelp Caching in Browser.

Post by kirkilj »

I just ran into this myself yesterday. I posted a new version of content and authors were looking for the changes that they had made and couldn't see them. Holding down the shift-key and doing a refresh brought in the new version, so the old version was cached in the browser. I wanted to see if there was a way to do this from Apache rather than edit the transform assets, and I came upon something like the following that can be placed in the .htaccess file for the WebHelp root directory:

Code: Select all

<filesMatch "\.(html|htm|js|css)$">
FileETag None
<ifModule mod_headers.c>
Header unset ETag
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"
</ifModule>
</filesMatch>
I like the option of specifying a pattern to match against in case different caching strategies are needed. I'll try this in a couple days. If there's some reason why this is a bad idea, I'm all ears.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Prevent WebHelp Caching in Browser.

Post by sorin_ristache »

If different caching strategies are needed for different directories on the web server then it surely sounds like a good idea.

The only disadvantage that I can see is a little slower access to the WebHelp pages due to the requirement to check all ancestor directories on the web server for .htaccess files.
Regards,
Sorin

<oXygen/> XML Editor Support
runleonarun
Posts: 9
Joined: Wed May 08, 2013 11:20 pm

Re: Prevent WebHelp Caching in Browser.

Post by runleonarun »

Do I need to run the ant -f integrator.xml in the DITA-OT after adding this info to the files?
bogdan_cercelaru
Posts: 222
Joined: Tue Jul 01, 2014 11:48 am

Re: Prevent WebHelp Caching in Browser.

Post by bogdan_cercelaru »

Hello,

No, you don't need to run "ant -f integrator.xml" after adding this.

Regards,
Bogdan
Bogdan Cercelaru
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
misti
Posts: 13
Joined: Wed Feb 03, 2016 10:05 pm

Re: Prevent WebHelp Caching in Browser.

Post by misti »

Any update on how to prevent caching for the Oxygen 20 webhelp responsive build?
bogdan_cercelaru
Posts: 222
Joined: Tue Jul 01, 2014 11:48 am

Re: Prevent WebHelp Caching in Browser.

Post by bogdan_cercelaru »

Hello,

Unfortunately we don't have a mechanism to invalidate the entire HTML files. This is controlled by the web server or the client browser.
More information about how browser caching works can be found here: https://developer.mozilla.org/en-US/doc ... TP/Caching

You can add the following header field in each HTML files
<meta http-equiv="Cache-control" content="no-cache" />
using the "webhelp.fragment.head" parameter. More information can be found here: https://www.oxygenxml.com/doc/versions/ ... gment_head

Regards,
Bogdan
Bogdan Cercelaru
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Post Reply