简体   繁体   中英

How to enable gzip compression for specific directory and tell browsers to cache it's contents?

I am using Oracle's ORDS 20.2 which has jetty/9.4.28.v20200408 embedded, APEX 20.1, Database 18c XE, Google Chrome Version 84.0.4147.135 (Official Build) (64-bit), opera Version:70.0.3728.106 and Windows 7 Ultimate.

In APEX there is a directory that has APEX's static files - CSS and Javascript files and image files. I need to enable gzip for that directory and tell the browser to cache it for at least 12 hours in order to improve performance for APEX development environment and my APEX applications according to Oracle's documentation here, https://docs.oracle.com/en/database/oracle/application-express/19.2/htmig/performance-optimization-tasks.html#GUID-668ED330-AFDC-4A43-AA11-D67FCCA58DA1

I've created a folder named "etc" under the "standalone" folder of my ORDS configuration directory. That's the folder where I should put any Jetty's Xml configuration files. Then created a file called "jetty.xml" with the following contents to implement what is in the Jetty's documentation about sending Cache-Control header, https://www.eclipse.org/jetty/documentation/current/header-filter.html And

    <?xml version="1.0"?>  
    <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN"   
    "http://www.eclipse.org/jetty/configure.dtd">  
    <filter>  
       <filter-name>HeaderFilter</filter-name>  
       <filter-class>org.eclipse.jetty.servlets.HeaderFilter</filter-class>  
       <init-param>  
         <param-name>headerConfig</param-name>  
         <param-value>  
          "add Cache-Control: max-age=43200"  
         </param-value>  
       <init-param>  
         <param-name>includedPaths</param-name>  
         <param-value>  
          "D:\ords\images"  
         </param-value>  
       </init-param>  
     </filter>  

But when I run ORDS through a batch file which has

    cd D:\Original\Oracle_ORDS_Editions\ords-20.2.0.178.1804
    d:
    java -jar ords.war standalone

the cmd window opens then vanishes automatically. I need to know why the code fails and still need to enable gzip for that directory. Thank you.

The HeaderFilter is for use with webapps that are traditionally deployed via a webapp archive (WAR file).

The documented configuration for HeaderFilter is for the war internal WEB-INF/web.xml servlet descriptor that is specific to the webapp being deployed (typically found within a WAR file).

Arbitrarily creating etc directories and jetty.xml files are never a relevant form of configuration for Jetty.

The etc directory and the jetty.xml concepts are only relevant if you are using the standalone Jetty techniques (such as what's seen in jetty-home or the older jetty-distribution archives). More specifically, the start.jar within the jetty-home archive is the only one that looks for and uses either the etc directory or the jetty.xml file.

The jetty.xml , that the start.jar is aware, of is never managed by manually creating it or editing it. In fact it's a typically a read-only file that comes with the jetty-home archive, and is used in-place. The etc directory is found within the jetty-home archive, and can also be seen in the application specific configuration of Jetty standalone known as the ${jetty.base} directory.

You mentioned "jetty/9.4.28.v20200408 embedded" which typically means it's not using the standalone Jetty concepts. In an embedded Jetty scenario, the configuration of the Jetty server is typically done within the configuration techniques of the parent project (Oracle ORDS in your case). You'll need to know how that Jetty server is configured, and work within the limits of whatever configuration that parent project provides to you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM