Skip to end of metadata
Go to start of metadata
Page Contents

The Apache web server works efficiently with BI platform because Apache caches static resources, such as JavaScript and HTML files, instead of storing them on the server. BI platform uses those files frequently, and Apache can serve them quickly from the cache.

In this pattern, mod_cache_disk is used to store cache on the local drive. This pattern does not use mod_cache_mem (for in-memory caching) because mod_cache_mem is bound to an individual process and does not persist when the service is restarted.

In this pattern, the static content is initially stored on Tomcat, but subsequent storage of static resources is cached for faster response.
For more information about creating a static content split, and manipulating headers, see Improving the User Experience in SAP BI Platform 4.0 with Apache and WDeploy.

Workflow and additional information

  • Prepare the file system.
    To use mod_cache, you must create a directory on the local machine where Apache has permissions to write files. It is recommended that the directory be separate from the Apache installation directory to avoid conflicts with existing permissions.
  • Configure mod_cache.
    The next step is to configure Apache to load and enable the mod_cache module.
  • Schedule the htcacheclean process for cache management.
    To manage disk space used by mod_cache, set up the Apache automated clean-up process named htcacheclean.
    htcacheclean can also be used from the command line to list the URL currently available in cache or to remove individual entities. For more information, go to http://httpd.apache.org/docs/current/en/programs/htcacheclean.html.
  • Test the cache.
    Test and confirm that the module is functioning as expected.
    Steps provided here are based on the "Cache Status and Logging" section of the "Apache Module mod_cache" page at http://httpd.apache.org/docs/current/en/mod/mod_cache.html.

It is recommended to take steps to avoid a multitude of requests being sent to the server when a page is not in the cache. For more information, see the section "Avoiding the thundering heard" at http://httpd.apache.org/docs/current/en/mod/mod_cache.html.

For more information about using a cache system with Apache, see http://httpd.apache.org/docs/current/en/caching.html.

To prepare the file system

  1. Log in to machine winpb01 using the account BI4PATTERN\BIPattern01.

  2. Go to the root drive (for example, C:), add a new Folder, and name it mod_cache



  3. Double-click the mod_cache folder and create a subfolder named cacheroot.

  4. At the same folder level as cacheroot, create another folder, and name it lock.




  5. To set security on the mod_cache folder, return to the root of C, right-click mod_cache, and select Properties.
    The "mod_cache Properties" dialog box opens.
  6. On the Security tab, set the permissions on the mod_cache folder:
    a) Click Edit > Add .
    The "Select Users, Computers, Service Accounts, or Groups" dialog box opens.

    b) In the Enter the object names to select box, type BI4PATTERN\SVC_WEBTIER.

    c) Grant Modify permissions to the mod_cache folder by selecting the check box in the Allow column.



    c) Click Apply, and click OK.

To configure mod_cache

  1. In a text editor, open this file C:\Apache24\conf\httpd.conf.

  2. To enable mod_cache and mod_cache_disk, uncomment the following lines:

    LoadModule cache_module modules/mod_cache.so
    LoadModule cache_disk_module modules/mod_cache_disk.so
    


  3. To configure mod_cache, scroll to the bottom of the file, and add the following lines:

    #Remove hostname from ETag so that identical files from winpb02
    #and winpb03 Tomcat are not cached separately
    FileETag MTime Size
    
    #====================Configure mod_cache==============
    <IfModule mod_cache.c>
    #Address the Thundering Herd identified in Apache’s Caching Guide CacheLock on
    CacheLockPath C:/mod_cache/lock
    CacheLockMaxAge 5
    
    
    #This parameter tells Apache to ignore unique session identifiers #when caching static content.
    #SAP BI Platform 4.0 uses the strings jsessionid and bttoken to
    #identify user sessions.
    
    CacheIgnoreURLSessionIdentifiers jsessionid bttoken
    
    #Don’t cache cookies as they are unique per user
    
    CacheIgnoreHeaders Set-Cookie
    
    #Enable mod_disk_cache instead of mod_mem_cache
    <IfModule mod_cache_disk.c>
    CacheRoot c:/mod_cache/cacheroot
    CacheEnable disk /
    CacheDirLevels 2
    CacheDirLength 1
    </IfModule>
    </IfModule>
    


    Apache 2.4 Name Change

    In Apache 2.2, mod_cache_disk was named mod_disk_cache. This name change results in a slightly different configuration to the IfModule section in the httpd.config file. The renaming of mod_disk_cache to mod_cache_disk is important to make note of when upgrading from Apache 2.2 to Apache 2.4.



  4. To enable mod_cache, restart the Apache service:
    a) Click Start > Run, and in the Open box type services.msc.
         The "Services" dialog box opens.
    b) Select Apache 2.4, and click Restart.

To schedule the htcacheclean process for cache management

On Windows, the htcacheclean process can be configured to run as a scheduled task to maintain the cache at a manageable size. On Linux, this process runs as a daemon, regularly maintaining the cache directory to ensure it doesn't grow too large.

Log On as a Batch Job

To schedule this process, the Log On as a Batch Job permission must be granted to the service account. This permission is often linked to a domain policy and may require a domain administrator to grant it.



  1. Open the Windows task scheduler:
    Click Start > Run, and in the Open box type control.exe schedtasks.
    The "Task Scheduler" dialog box opens.
  1. Right-click Task Scheduler Library and select Create Basic Task.
    The "Create Basic Task" wizard opens.

  2. In the Name box, type htcacheclean.
  3. In the Description box, type a description of what htcacheclean will be used for (see screenshot for an example), and then click Next



  4. On the "Task Trigger" page, select When the computer starts, and click Next.

  5. On the "Action" page, select Start a program, and click Next.

  6. On the "Start a Program" page, in the Program/script box, type the following:

    C:\Apache24\bin\htcacheclean.exe

  7. In the Add arguments (optional) box, add the following arguments, and then click Next:

    -d 480 -n -p C:/mod_cache/cacheroot -l 500M --i

    Type the optional commands but do not copy them. The characters are not preserved correctly when using clipboard and it can cause the htcacheclean process to fail



  8. Select the Open the properties dialog for this task when I click Finish check box, and click Finish.



  9. Click the Change User or Group button, type BI4PATTERN\SVC_WEBTIER*, and then click OK.

  10. Click Run whether user is logged on or not, select the Do not store password check box, and then click OK.
  11. This scheduled task does not require access to non-local resources.



  12. For the password, type WebTier*123.
  13. Right-click the htcacheclean task, and click Run.

  14. Right-click the Windows task bar, and select Start Task Manager.
    The "Windows Task Manager" dialog box opens.  
  15. On the Processes tab, click Show Processes from all Users.
    The htcacheclean.exe process appears in the list.



    This scheduled task will cause htcacheclean to run every 480 minutes (8 hours), with a goal of keeping the overall cache at 500 MB. The process will consume minimal system resources and take action only when it detects a modification to the cache.

To test the cache

Testing is especially important with a dynamic application such as BI platform to ensure that private data is not shared between clients.

  1. In a text editor, open C:\Apache24\conf\httpd.conf.

  2. To have the cache record a log file, scroll to the bottom of the httpd.conf file, and add the following lines:

    LogFormat "%h %l %u %t \"%r\" %{cache-status}e %>s %b" cache
    CustomLog logs/mod_cache.log cache
    


    This block of code configures a custom logging format that contains the Apache variable %{cache-status}, and prints each request to a log file named mod_cache.log.

    The output records the content that is served from cache, and when content is not served from the cache, the log will record the reasons why.



  3. Save and close the file.

  4. Run the following commands to stop Apache and clear the logs directory for easier reading:

    a) Click Start > Run, and in the Open box type services.msc.
        The "Services" dialog box opens.
    b) Select the Apache 2.4 service, and click Stop.
    c) Click Start > Run, and in the Open box type C:\Apache24\logs.
        The "logs" dialog box opens.
    d) Select all files (access and error logs are displayed), and delete them.
    e) Return to the "Services" dialog box, select the Apache 2.4 service, and click Start.
    f) Return to the "logs" dialog box, and ensure that a new file named mod_cache has been created.



  5. Open Internet Explorer, go to the BI Launch Pad: http://vantgvmwinpb01.dhcp.pgdev.sap.corp/BOE/BI.
  6. In the User Name box, type Administrator, and for the password type Pattern123.
  7. Return to the "logs" dialog box, and double-click the mod_cache file.

    Note the following lines that contain details about a cache "miss":

    "GET /BOE/portal/1212190046/shared/js/accessibility/accessibility_util.js HTTP/1.1" cache miss: attempting entity save

  8. Close the file, and return to Internet Explorer.

  9. To ensure requests are sent to Apache, clear the browser cache:
    a) Click Tools > Internet Options > Browsing History > Delete > Delete > Ok.
    b) Click Log Off at the top of the BI Launch Pad.
    c) Log in again to BI Launch Pad, with the user name Administrator and password Pattern123.
    d) Press F5 on your keyboard to ensure the page is actively refreshed.

  10. Return to the "logs" dialog box, and open the mod_cache file.

  11. Note that the most recent request for accessibility_util.js now displays "cache hit":

    "GET /BOE/portal/1212190046/shared/js/accessibility/accessibility_util.js HTTP/1.1" cache hit

This indicates that mod_cache is now configured correctly.

  • No labels