WebDev and GZip compression?

Posting this to the “Ignition” section to see if it gets more attention :slight_smile:

Wondering if there is a way to enable caching and/or Gzip compression for REST Webdev calls? I would think that those are enabled at the Web Server level, but do we have access to those settings?

Adding more details here after some research:

It looks like on the later versions of Jetty, gzip compression is enabled via gzip.mod, and enabled via the jetty-gzip.xml or a “context xml” file. Not sure where those reside?
https://www.eclipse.org/jetty/documentation/9.3.22.v20171030/gzip-filter.html1

In earlier versions, a gzip handler can be added to web.xml (/ignition/webserver/webapps/main/WEB-INF/web.xml); but that approach is no longer supported? Can someone confirm?

IA Support has confirmed that enabling the above does not affect the Webserver and GZip compression is not turned on after.

Edit: removed my solution as it only worked when .gz files were requested.

Courtesy of @PerryAJ :
Add a file called jetty-web.xml to Ignition\webserver\webapps\main\WEB-INF with the following:


<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
    <Set name="GzipHandler">
        <New class="org.eclipse.jetty.server.handler.gzip.GzipHandler"/>
    </Set>
</Configure>

Not sure if this will break anything else :sweat_smile:

1 Like

Sweet! Thanks @ethan.thomason and @PerryAJ

I will test this on our dev server tomorrow.

Oscar

Quick update on this:
Adding a jetty-web.xml file to Ignition\webserver\webapps\main\WEB-INF (with the content in your post) does not seem to have enabled Gzip compression on webdev calls to the Gateway.
There is already a file in that folder called web.xml, should I just add to that file instead of adding a new file named differently?
Here are the contents of the existing web.xml file:

<?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" id="SRGateway" version="2.5">
  <display-name>Ignition</display-name>
  <context-param>
  	<param-name>configuration</param-name>
  	<param-value>deployment</param-value>
  </context-param>
  <context-param>
    <param-name>lib.dir</param-name>
    <param-value>lib\</param-value>
  </context-param>
  <context-param>
    <param-name>data.dir</param-name>
    <param-value>data\</param-value>
  </context-param>
  <context-param>
    <param-name>userlib.dir</param-name>
    <param-value>user-lib\</param-value>
  </context-param>
  <context-param>
    <param-name>logs.dir</param-name>
    <param-value>logs\</param-value>
  </context-param>
  <context-param>
    <param-name>temp.dir</param-name>
    <param-value>temp\</param-value>
  </context-param>
  <context-param>
    <param-name>etc.dir</param-name>
    <param-value>/etc/ignition/</param-value>
  </context-param>
  <context-param>
    <param-name>org.eclipse.jetty.servlet.SessionIdPathParameterName</param-name>
    <param-value>none</param-value>
  </context-param>
  
  <filter>
  	<filter-name>WicketFilter</filter-name>
  	<filter-class>com.inductiveautomation.ignition.gateway.bootstrap.SRFilter</filter-class>
  	<init-param>
  	  <param-name>applicationClassName</param-name>
  	  <param-value>com.inductiveautomation.ignition.gateway.SRContext</param-value>
  	</init-param>
  	<init-param>
  	  <param-name>filterMappingUrlPattern</param-name>
  	  <param-value>/web/*</param-value>
  	</init-param>
  </filter>
  <filter-mapping>
  	<filter-name>WicketFilter</filter-name>
  	<url-pattern>/web/*</url-pattern>
  </filter-mapping>
  
  <servlet>
    <servlet-name>Map</servlet-name>
    <servlet-class>com.inductiveautomation.ignition.gateway.bootstrap.MapServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
  	<servlet-name>Map</servlet-name>
  	<url-pattern>/system/*</url-pattern>
  </servlet-mapping>

  <servlet>
      <servlet-name>Resources</servlet-name>
      <servlet-class>com.inductiveautomation.ignition.gateway.bootstrap.ResourceServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
      <servlet-name>Resources</servlet-name>
      <url-pattern>/res/*</url-pattern>
  </servlet-mapping>
  
  <servlet>
    <servlet-name>DataRoutes</servlet-name>
    <servlet-class>com.inductiveautomation.ignition.gateway.bootstrap.DataServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    <multipart-config>
      <max-file-size>20848820</max-file-size>
      <max-request-size>418018841</max-request-size>
      <file-size-threshold>1048576</file-size-threshold>
    </multipart-config>
  </servlet>
  <servlet-mapping>
    <servlet-name>DataRoutes</servlet-name>
    <url-pattern>/data/*</url-pattern>
  </servlet-mapping>

  <servlet>
  	<servlet-name>Start</servlet-name>
  	<servlet-class>com.inductiveautomation.ignition.gateway.bootstrap.StartupServlet</servlet-class>
  </servlet>
  <servlet-mapping>
  	<servlet-name>Start</servlet-name>
  	<url-pattern>/Start</url-pattern>
  </servlet-mapping>
  
  <servlet>
  	<servlet-name>StatusPing</servlet-name>
  	<servlet-class>com.inductiveautomation.ignition.gateway.bootstrap.StatusPingServlet</servlet-class>
  </servlet>
  <servlet-mapping>
  	<servlet-name>StatusPing</servlet-name>
  	<url-pattern>/StatusPing</url-pattern>
  </servlet-mapping>
  
  <welcome-file-list>
  	<welcome-file>Start</welcome-file>
  </welcome-file-list>
</web-app>

I don’t see a section to plug the GzipHandler option in.

Thanks!
Oscar.

Ignore that, I read the documentation and it does need to be a jetty-web.xml (or web-jetty.xml).

Did you do a gateway restart after adding the file? How are you checking the compression (Chrome, Wireshark, etc) ? Any errors in the logs?