Page 1 of 1

Prevent WebHelp Caching in Browser.

Posted: Wed Apr 02, 2014 8:57 pm
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!!

Re: Prevent WebHelp Caching in Browser.

Posted: Thu Apr 03, 2014 3:28 pm
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

Re: Prevent WebHelp Caching in Browser.

Posted: Wed Dec 17, 2014 9:38 pm
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.

Re: Prevent WebHelp Caching in Browser.

Posted: Thu Dec 18, 2014 10:36 am
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.

Re: Prevent WebHelp Caching in Browser.

Posted: Tue Apr 18, 2017 3:26 am
by runleonarun
Do I need to run the ant -f integrator.xml in the DITA-OT after adding this info to the files?

Re: Prevent WebHelp Caching in Browser.

Posted: Tue Apr 18, 2017 3:23 pm
by bogdan_cercelaru
Hello,

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

Regards,
Bogdan

Re: Prevent WebHelp Caching in Browser.

Posted: Mon May 21, 2018 4:03 pm
by misti
Any update on how to prevent caching for the Oxygen 20 webhelp responsive build?

Re: Prevent WebHelp Caching in Browser.

Posted: Tue May 29, 2018 2:43 pm
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