Re: caching javascript and other secondary resource files

2019-06-27 Thread Alan Stange
Martin,

Thank you for your reply.   I spent some time stepping through the
application in a debugger and came to the same conclusion.   I did see a
few things that might be small improvements.

For example, in WIcketServlet.java, getURL() strips the leading '/' off the
URL before returning it to fallback(), which promptly adds it back on.   It
looks like this extra garbage generation could be avoided.

Alan

On Thu, Jun 27, 2019 at 2:04 AM Martin Grigorov 
wrote:

> Hi,
>
> If you don't use Wicket ResourceReference for the resource
> (js/css/image/...) then Wicket will not do anything for it.
> Still you have the following options:
> - use a custom Servler Filter that adds the caching response headers for
> any resource that does not have them. This filter should be configured
> before WicketFilter in web.xml or annotations so that it wraps around it
> - configure Jetty (or the frontend proxy if you use one (e.g. Apache HTTPD
> or Nginx)) to set the missing headers
>
> On Wed, Jun 26, 2019 at 10:24 PM Alan Stange  wrote:
>
> > All,
> >
> > We've been using Wicket for some time now and are looking to improve the
> > caching of javascript resources in our web app.   Explicit headers are
> > being cached by the usual mechanism of calling
> >  JavascriptHeaderItem.forReference().   The cases I'm having trouble with
> > is when a javascript file is referencing another script, or a css file
> has
> > a .png file in a url().
> >
> > Is there a way that I can say "All the static content in directory X (in
> > the war file) and below is to be cached using the typical Wicket
> > mechanisms"?
> >
> > As an example, pdf.js will require() pdf.worker.js, which is a 1.5MB
> file.
> >   But I don't have control over the url being required.   How can I tell
> > wicket to enable the caching headers for requests to file "pdf.worker.js"
> > or "images/leftButton.png" with a 3600 second life.
> >
> > I've read through the docs and tried several options suggested and
> nothing
> > seems to work.   I'm using Wicket 8.x under Jetty 9.4.19.
> >
> > Thank you,
> >
> > Alan
> >
>


Re: caching javascript and other secondary resource files

2019-06-26 Thread Martin Grigorov
Hi,

If you don't use Wicket ResourceReference for the resource
(js/css/image/...) then Wicket will not do anything for it.
Still you have the following options:
- use a custom Servler Filter that adds the caching response headers for
any resource that does not have them. This filter should be configured
before WicketFilter in web.xml or annotations so that it wraps around it
- configure Jetty (or the frontend proxy if you use one (e.g. Apache HTTPD
or Nginx)) to set the missing headers

On Wed, Jun 26, 2019 at 10:24 PM Alan Stange  wrote:

> All,
>
> We've been using Wicket for some time now and are looking to improve the
> caching of javascript resources in our web app.   Explicit headers are
> being cached by the usual mechanism of calling
>  JavascriptHeaderItem.forReference().   The cases I'm having trouble with
> is when a javascript file is referencing another script, or a css file has
> a .png file in a url().
>
> Is there a way that I can say "All the static content in directory X (in
> the war file) and below is to be cached using the typical Wicket
> mechanisms"?
>
> As an example, pdf.js will require() pdf.worker.js, which is a 1.5MB file.
>   But I don't have control over the url being required.   How can I tell
> wicket to enable the caching headers for requests to file "pdf.worker.js"
> or "images/leftButton.png" with a 3600 second life.
>
> I've read through the docs and tried several options suggested and nothing
> seems to work.   I'm using Wicket 8.x under Jetty 9.4.19.
>
> Thank you,
>
> Alan
>


caching javascript and other secondary resource files

2019-06-26 Thread Alan Stange
All,

We've been using Wicket for some time now and are looking to improve the
caching of javascript resources in our web app.   Explicit headers are
being cached by the usual mechanism of calling
 JavascriptHeaderItem.forReference().   The cases I'm having trouble with
is when a javascript file is referencing another script, or a css file has
a .png file in a url().

Is there a way that I can say "All the static content in directory X (in
the war file) and below is to be cached using the typical Wicket
mechanisms"?

As an example, pdf.js will require() pdf.worker.js, which is a 1.5MB file.
  But I don't have control over the url being required.   How can I tell
wicket to enable the caching headers for requests to file "pdf.worker.js"
or "images/leftButton.png" with a 3600 second life.

I've read through the docs and tried several options suggested and nothing
seems to work.   I'm using Wicket 8.x under Jetty 9.4.19.

Thank you,

Alan