0
votes

I have a Google Appengine Java application that I use to host a simple static website.

My .html, .css, .jpg files go in the war directory. Here's my 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>

Here's my 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>

I would like to do serve webp version of images whenever possible. How can I do this?

I conducted a simple experiment. I have file.jpg and corresponding file.webp in my war directory. I have a home.html page that refers to file.jpg. When I access home.html on Google Chrome -- the jpg is served not the webp.

1
hm, can you remind why Google Chrome must lost different image at this case? - Igor Artamonov
@IgorArtamonov webp images tend to be smaller than corresponding jpegs, this can significantly reduce load times of a page. This is probably one of the major reasons that google got behind webp in the first place -- faster internet. Google Chrome and Opera are the only major browsers that support webp at this point of time. When Chrome asks for an image from a server it sends an accept header stating that it can accept a webp. - AmaltasCoder
sorry, lost -> load in my previous comment - Igor Artamonov
I'm asking why it should load different url? You have url /images/image.jpg in your html, right? How chrome should figure out that this image url is invalid and it must be using /images/image.webp instead? - Igor Artamonov

1 Answers

0
votes

If you can change JavaScript code, it'll be easier to do it there: https://developers.google.com/speed/webp/faq#how_can_i_detect_browser_support_for_webp