Hi Chris!

Tapestry's AssetDispatcher/ResourcerStreamer does ETag for assets:

https://github.com/apache/tapestry-5/blob/b01afbedb325897084ab5f2277e99a0e6fe2a02f/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ResourceStreamerImpl.java#L156-L171

You could implement the BLOB-based images as assets, so it will use that
system, too.
We went that route for SCSS support in our applications.

You'd require a custom AssetFactory and AssetRequestHandler.
If you look at the implementations Tapestry has, it's not that complicated.
Then, you'd contribute the factory to AssetSource, and the RequestHandler
to Dispatcher with the @AssetRequestDispatcher annotation.

I think that should do it.

Alternatively, you could use an HttpServletRequestFilter, but you would
need to do all the ETag logic/handling yourself.
And you'd lose everything Tapestry brings to the table for assets, like
referencing them via prefix and automatic URL generating, etc.

Cheers
Ben

On Sat, Oct 5, 2024 at 6:07 AM Christopher Dodunski (Tapestry) <
chrisfromtapes...@christopher.net.nz> wrote:

> Hello all,
>
> I’m exploring the possibility of adding ETag headers to images my
> Tapestry application is serving, to help improve performance on slower
> networks.
>
> It seems that Apache Server automatically adds ETag headers to images
> sourced from static files (Tapestry @Asset), but not when Tapestry
> dynamically generates an image from a database BLOB (and without file
> extension, eg. .png).
>
> Essentially, the app would need to return a “304 Not Modified” in
> response to a conditional If-None-Match request from the client, if the
> image hadn’t changed.
>
> I couldn’t find anything about this in the Tapestry docs, and am
> wondering how others might have implemented ETag headers within their
> Tapestry applications.
>
> Kind regards,
>
> Chris.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

Reply via email to