org.eclipse.jetty.servlets.PushCacheFilter class in Java implements javax.servlet.Filter interface to identify resources to be pushed to a browser. The former class is provided by Jetty to implement HTTP/2 Push services for a client-server interaction. How should we use the functionalities of this class in our Java based web projects? How do we deploy them ? Specifically:- My server has a list of files which needs to be pushed onto a client. Which methods should I call to leverage the HTTP/2 Push ? How do we deploy these classes into our web apps folder of jetty ?
Jetty proposes an extension to the Servlet API (to be included in Servlet 4.0) that allows to push resources programmatically.
Jetty's PushCacheFilter
just uses these APIs to push resources, and adds logic to dynamically track resources to push, so that it "learns" what to push.
If you have a different use case where you know beforehand what to push, and you don't need any of the logic performed by PushCacheFilter
, then you can write your own Jetty Handler
or Servlet filter that performs your logic.
This question's answer details the APIs to use.