【问题标题】:Apache Expires Directive on WildflyApache 在 Wildfly 上过期指令
【发布时间】:2021-10-06 04:17:08
【问题描述】:

有什么方法可以使用 undertow-handlers 或 Standalone.xml 在 Wildfly 上复制 Apache Expires Directive 功能。以下是指令-

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault "access plus 1 seconds"
    ExpiresByType text/html "access plus 1 seconds"
    ExpiresByType image/gif "access plus 120 minutes"
    ExpiresByType image/jpeg "access plus 120 minutes"
    ExpiresByType image/png "access plus 120 minutes"
    ExpiresByType text/css "access plus 60 minutes"
    ExpiresByType text/javascript "access plus 60 minutes"
    ExpiresByType application/x-javascript "access plus 60 minutes"
    ExpiresByType text/xml "access plus 60 minutes"
</IfModule>

浏览 Wildfly 文档并没有多大帮助。

【问题讨论】:

  • 你是指整个服务器还是单个 webapp?一个非常简单的过滤器可以做到这一点,但我认为没有内置任何东西。
  • @stdunbar 我们需要在哪个级别实现过滤器?我们该怎么做?

标签: java jboss wildfly undertow


【解决方案1】:

没有为类型设置标题的内置方法,但您可以使用 suffices 代替。 您可以为特定后缀配置response-header 过滤器。在您的示例中,您需要一个 filter-ref 和一个 response-header 用于一种类型的所有后缀。

<subsystem xmlns="urn:jboss:domain:undertow:1.2">

  ...

  <server name="default-server">

    ...

    <host name="default-host" alias="localhost">
        ...
        <filter-ref name="custom-max-age" predicate="path-suffix['.js'] or path-suffix ['.json'] or path-suffix ['.html'] or path-suffix ['.css'] or path-suffix ['.jpg'] or path-suffix ['.jpeg'] or path-suffix ['.png'] or path-suffix ['.gif']"/>
    </host>
  </server>

  ...

  <filters>

      ...
      
      <response-header name="custom-max-age" header-name="Cache-Control" header-value="max-age=600, public"/>
  </filters>
</subsystem>

source

【讨论】:

    猜你喜欢
    • 2016-03-22
    • 2012-01-30
    • 1970-01-01
    • 2012-07-10
    • 1970-01-01
    • 2018-02-01
    • 1970-01-01
    • 2020-07-17
    • 2012-04-28
    相关资源
    最近更新 更多