Tuesday, June 10, 2014

How To Disable Caching In WebHelp Pages Created By Oxygen Application

Share to Facebook Share to Twitter Email This Share on Google Plus Share on Tumblr
Sometimes a set of WebHelp pages needs to be updated often on a company website, either an intranet site with important information shared between different departments of the same company, or a publicly exposed website. The need to always deliver the latest version to the intended audience arises in such cases, with the immediate consequence that the latest version of a WebHelp page should always be requested from the server upon re-loading that page in a Web browser on the client side, rather than re-using an outdated version cached in the browser.

This no-cache policy is implemented in a WebHelp page with the addition of the following two HTML META directives:

  <meta http-equiv="Pragma" content="no-cache" />
  <meta http-equiv="Expires" content="-1" />


These directives must be added in the file:


OXYGEN_INSTALL_DIR\frameworks\dita\DITA-OT\plugins\com.oxygenxml.webhelp\xsl\createMainFiles.xsl


in the template with the attribute name="create-toc-common-file", in the <head> element, for example:


  <html>
    <head>
      <xsl:if test="$withFrames">
          <base target="contentwin"/>
      </xsl:if>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
      
      <!-- Disable caching of WebHelp pages in web browser. -->
      <meta http-equiv="Pragma" content="no-cache" />
      <meta http-equiv="Expires" content="-1" />
      .  .  .


After this modification in the createMainFiles.xsl file, repeating the WebHelp transformation in Oxygen will add the two META directives to the generated WebHelp pages.

11 comments:

  1. Anonymous11:35 PM

    Thank you for the tips. Is it possible to do that only for WebHelp Feedback, while leaving WebHelp Desktop/Mobile intact?

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. Yes, it is possible. The two <meta> elements would have to be enclosed in an <xsl:if> element which checks if we are in a Webhelp-Feedback transformation:


      <xsl:if test="string-length($WEBHELP_PRODUCT_ID) > 0">
      <meta http-equiv="Pragma" content="no-cache" />
      <meta http-equiv="Expires" content="-1" />
      </xsl:if>


      Two more additions are necessary:

      1. The WEBHELP_PRODUCT_ID parameter needs to be declared in the same XSL file:


      <xsl:param name="WEBHELP_PRODUCT_ID" select="''"/>


      2. The WEBHELP_PRODUCT_ID parameter needs to be set by the Webhelp-Feedback transformation by adding the following line:


      <param name="WEBHELP_PRODUCT_ID" expression="${webhelp.product.id}" if="webhelp.product.id"/>


      in the following ANT build file:

      OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT/plugins/com.oxygenxml.webhelp/build_dita.xml

      inside the <xslt> element that starts at line 181 and that runs the above createMainFiles.xsl stylesheet.

      Delete
    3. Anonymous9:18 PM

      With your help, I succeeded in implementing similar changes. Thanks!

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Anonymous12:55 AM

    Thanks

    ReplyDelete
  5. Anonymous5:18 PM

    Hello,
    I would like to overwrite the createMainFiles.xsl file (i.e. not change its content but create a custom xsl that will overwrite it).
    However, in the transformation scenario, I can only find the args.xsl parameter (which overwrites dita2xhtml.xsl).
    Can you explain how I can overwrite createMainFiles.xsl?
    Thanks

    ReplyDelete
  6. Hello,

    We plan to add in a future version one or more extension points for the XSLT stylesheets of the Webhelp transformation, which will allow you to do that. In the current version (16.0) you have to edit and modify the createMainFiles.xsl file, if the customization that you need can't be done in other way (for example with a custom CSS stylesheet, which can be set as a parameter of the Webhelp transformation). Please can you tell us what you want to customize in the Webhelp pages?


    Regards,
    Sorin

    ReplyDelete
  7. Anonymous4:25 PM

    Hi again,
    Thanks for your quick answer.
    I have done most of my customizations in the CSS, but there are three I could only do in CreateMainFiles.xsl:

    - the favicon

    - in the header section, in the div id="productTitle", I have replaced the "print this page" logo with my custom logo (including a link to my website)

    - I then display the "print this page" logo in a table cell added under the "parent topic" link.

    I hope this is clear enough.
    Thanks in advance for your help

    ReplyDelete
    Replies
    1. Hi,

      The customization of the print icon (the print icon itself and its location) should be possible in the Webhelp Skin Builder (http://www.oxygenxml.com/webhelp-skin-builder/). A minor customization is already possible for the print icon but not enough for the changes that you want. We will improve the Skin Builder for that.

      Unfortunately for the favicon you have to modify the XSLT stylesheet as described on this blog. We will add the possibility to override the WebHelp XSLT stylesheets in a future version so that you can just add your own XSLT file that contains only the customized feature of the WebHelp pages.


      Regards,
      Sorin

      Delete