HTML5(4) -- Weblogic下启用Gzip压缩静态资源

具体参加:http://www.cnblogs.com/interdrp/p/3708167.html

具体项目实例:

tk-filters.properties文件

#
# This properties file controls the behavior of the various
# filters available in the Tacit Knowledge filters package.
#
# Each filter has its own set of configuration directives,
# prefixed with the filter name, that controls that specific
# filter's behavior
#


#########################################################################
#                         ClusterCheck
#########################################################################
# A frequent problem when clustering is that applications use the session
# in a non-clusterable way, so The "ClusterCheckFilter" instruments the 
# application server's sessions with checks to see if this is a problem.
ClusterCheckFilter.Enabled=false

# Its possible to check for modifications to session objects after
# they have been set in to the session. This is a problem for sessions
# that are replicated in a copy-on-write fashion
ClusterCheckFilter.UnsetModificationsCheck=false

# Its possible to check serialized size to ensure high performance clustering
ClusterCheckFilter.ByteSizeCheck=false

# Aggregate size is important for containers that serialize the whole session
# every time. An example would be a database-backed session store.
# An aggregate size limit will also cap the maximum RAM used by sessions,
# allowing you to quantify the RAM necessary for peak loads.
ClusterCheckFilter.AggregateByteSizeLimit=30720

# Attribute size is important because each time an attribute is put in a
# session, it has to be serialized and persisted to a cluster peer, or
# to a database (depending on clustering implementations). Thus, very large
# session attributes will be a performance problem.
ClusterCheckFilter.AttributeByteSizeLimit=20480

# ClusterCheck errors can return a 500 error to the client
# in order to have "fail-fast" behavior, if this is turned on.
# This is good for test machines, but is usually too aggressive for production.
ClusterCheckFilter.ClientError=false
#########################################################################



#########################################################################
#                          GZIPFilter
#########################################################################
# A performance boost can be achieved by sending data from the application
# server to the client using the Gzip encoding. This incurs a small CPU
# cost to gain a large network benefit. The GZIPFilter, when enabled, 
# transparently Gzip encodes all data after it leaves the application,
# but before its transmitted to the client.

# WARNING: GZIPFilter is currently not recommended for production use.
#          It does not send all data under certain conditions.
GZIPFilter.Enabled=true

# Its possible for the GZIPFilter to log statistics about the compression
# ratios and byte savings it is achieving. This turns that on or off.
GZIPFilter.LogStats=false
#########################################################################



#########################################################################
#                          CacheFilter
#########################################################################
# A server can send expiration headers to the client, enabling the client 
# to confidently cache certain pieces of static content. This eliminates 
# unnecessary conditional GETs from the client to validate the freshness of
# content. If the application is on a server that doesn't do that, this
# filter can be enabled and mapped to static content (images, javascript,
# css files, etc), potentially reducing network traffic a great deal.
CacheFilter.Enabled=true

# This is the number of minutes the client will wait before verifying the
# freshness of a piece of content.
CacheFilter.ExpirationMinutes=15
#########################################################################

web.xml 文件

<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<!--
  - This is the Cocoon web-app configurations file
  -
  - $Id$
  -->
<web-app version="2.4"
         xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

  <!-- GZIPFilter files-->
  <filter>
    <filter-name>GZIPFilter</filter-name>
    <filter-class>com.tacitknowledge.filters.gzipfilter.GZIPFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>GZIPFilter</filter-name>
    <url-pattern>*.css</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>GZIPFilter</filter-name>
    <url-pattern>*.js</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>GZIPFilter</filter-name>
    <url-pattern>*.html</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>GZIPFilter</filter-name>
    <url-pattern>*.htm</url-pattern>
  </filter-mapping>

  <!-- CacheFilter files -->
  <filter>
    <filter-name>CacheFilter</filter-name>
    <filter-class>com.tacitknowledge.filters.cache.CacheHeaderFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>CacheFilter</filter-name>
    <url-pattern>*.gif</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>CacheFilter</filter-name>
    <url-pattern>*.jpg</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>CacheFilter</filter-name>
    <url-pattern>*.png</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>CacheFilter</filter-name>
    <url-pattern>*.js</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>CacheFilter</filter-name>
    <url-pattern>*.css</url-pattern>
  </filter-mapping>

  <welcome-file-list>
    <welcome-file>/*.html</welcome-file>
    <welcome-file>/*.htm</welcome-file>
  </welcome-file-list>
</web-app>
        

 

posted @ 2017-04-24 14:22  xu_shuyi  阅读(433)  评论(0)    收藏  举报