[英]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.我正在使用 Oracle 的 ORDS 20.2,它嵌入了 jetty/9.4.28.v20200408、APEX 20.1、Database 18c XE、Google Chrome 版本 84.0.4147.135(官方版本)(64 位)、opera 版本:70.0.3728.7 Ultimate 和 Windows .
In APEX there is a directory that has APEX's static files - CSS and Javascript files and image files.在 APEX 中有一个目录,其中包含 APEX 的静态文件 - CSS 和 Javascript 文件以及图像文件。 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我需要为该目录启用 gzip 并告诉浏览器将其缓存至少 12 小时,以便根据此处的 Oracle 文档提高 APEX 开发环境和我的 APEX 应用程序的性能, 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.我在我的 ORDS 配置目录的“独立”文件夹下创建了一个名为“etc”的文件夹。 That's the folder where I should put any Jetty's Xml configuration files.这是我应该放置任何 Jetty 的 Xml 配置文件的文件夹。 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然后创建一个名为“jetty.xml”的文件,其中包含以下内容以实现 Jetty 文档中关于发送 Cache-Control 标头的内容, https://www.eclipse.org/jetty/documentation/current/header-filter.html和
<?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但是当我通过一个批处理文件运行 ORDS 时
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. cmd 窗口打开然后自动消失。 I need to know why the code fails and still need to enable gzip for that directory.我需要知道为什么代码失败并且仍然需要为该目录启用 gzip。 Thank you.谢谢你。
The HeaderFilter
is for use with webapps that are traditionally deployed via a webapp archive (WAR file). HeaderFilter
用于传统上通过 webapp 存档(WAR 文件)部署的 webapp。
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). HeaderFilter
的文档配置适用于特定于正在部署的 web 应用程序的 war 内部WEB-INF/web.xml
servlet 描述符(通常在 WAR 文件中找到)。
Arbitrarily creating etc
directories and jetty.xml
files are never a relevant form of configuration for Jetty.随意创建etc
目录和jetty.xml
文件从来都不是 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). etc
目录和jetty.xml
概念仅在您使用独立的 Jetty 技术(例如在jetty-home
或较旧的jetty-distribution
存档中看到的内容)时才相关。 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.更具体地说, start.jar
的内jetty-home
档案是唯一一个看起来并既可使用etc
目录或jetty.xml
文件。
The jetty.xml
, that the start.jar
is aware, of is never managed by manually creating it or editing it.该jetty.xml
,该start.jar
知道的永远不会被手动创建或编辑它管理。 In fact it's a typically a read-only file that comes with the jetty-home
archive, and is used in-place.事实上,它是一个典型的只读文件,随jetty-home
存档一起提供,并就地使用。 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. etc
目录位于jetty-home
存档中,也可以在 Jetty Standalone 的应用程序特定配置中看到,称为${jetty.base}
目录。
You mentioned "jetty/9.4.28.v20200408 embedded" which typically means it's not using the standalone Jetty concepts.您提到了“jetty/9.4.28.v20200408 嵌入式”,这通常意味着它没有使用独立的 Jetty 概念。 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).在嵌入式 Jetty 场景中,Jetty 服务器的配置通常在父项目(在您的案例中为 Oracle ORDS)的配置技术中完成。 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.您需要知道 Jetty 服务器的配置方式,并在父项目提供给您的任何配置的限制范围内工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.