启用Google App Engine Java以在客户端接受它们时提供webp图像

时间:2016-06-30 09:07:53

标签: google-app-engine webp

我有一个Google Appengine Java应用程序,用于托管一个简单的静态网站。

我的.html,.css,.jpg文件进入war目录。这是我的web.xml

<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>
</web-app>

这是我的appengine-web.xml

<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
  <application>myapp</application>
  <version>5</version>

  <!--
    Allows App Engine to send multiple requests to one instance in parallel:
  -->
  <threadsafe>true</threadsafe>

  <!-- Configure java.util.logging -->
  <system-properties>
    <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
  </system-properties>

  <static-files>
    <include path="/**.png" expiration="7d" />
    <include path="/**.gif" expiration="7d" />
    <include path="/**.jpg" expiration="7d" />
    <include path="/**.jpeg" expiration="7d" />
    <include path="/**.tif" expiration="7d" />
    <include path="/**.tiff" expiration="7d" />

    <include path="/**.svg" expiration="7d" />
    <include path="/**.eot" expiration="7d" />
    <include path="/**.ttf" expiration="7d" />
    <include path="/**.woff" expiration="7d" />

    <include path="/**.webp" />

    <include path="/**.ico" />
    <include path="/**.html" />
    <include path="/**.css" />
    <include path="/**.js" />
    <include path="/**.zip" />
    <include path="/**.msi" />    
    <include path="/**.exe" />    
    <include path="/**.xml" />    
    <include path="/**.txt" />    
    <include path="/**.htc" />
  </static-files>

</appengine-web-app>

我想尽可能地提供webp版本的图像。我怎么能这样做?

我进行了一个简单的实验。我的war目录中有file.jpg和相应的file.webp。我有一个home.html页面,引用file.jpg。当我在Google Chrome上访问home.html时,jpg不是通过网络提供的。

1 个答案:

答案 0 :(得分:0)

如果您可以更改JavaScript代码,那么在那里更容易实现:https://developers.google.com/speed/webp/faq#how_can_i_detect_browser_support_for_webp