Http 2 Push wildcard or directory

Is it possible to push all the images or script in a given folder?
I don’t really need it now, I can list the resources since they are not so many.

What would be convenient is to have Caddy pick up new assets so I don’t have to reconfigure the Caddyfile
just because I added a couple of images or scripts that are rendered everywhere.

I guess this is a feature request so I created a github issue: https://github.com/mholt/caddy/issues/2135

That isn’t the intended use for HTTP/2 Server Push. It more for optimising the critical render path for best perceived page loading times i.e. critical css, js files which are needed to render the page above fold. Pushing all images within a directory isn’t one of those ideal use cases and probably do the opposite in increasing the perceived page load times and HTTP/2 generally negate that requirement anyway.

You can use something like Google Lighthouse too to optimise the critical render path’s assets Lighthouse  |  Tools for Web Developers  |  Google Developers or Webpagetest.org with advance chrome checked Lighthouse test inclusion.

example of using Google Lighthouse on caddy forums

It’s more about letting the app developer not having to micro manage every server push config.
It’s not a matter of pushing loads of images but allowing the developers to change which images are pushed simply by replacing, adding or deleting images in certain folders.

I understand your intentions though for images pushing them isn’t really needed or optimal. CSS and JS files yes but not images. Think how it would go down on a client’s slow 3G mobile connection and many images being pushed.

Yes, pushing a lot of assets all the time is not good but I still think at least the directory specification would be nice. You could then specify 2 separate directories /css and /js to load stuff that are genuinely push friendly and manually specifying image resources that are common for example logos etc.

The harmful performance effects of pushing lots of files is amplified by the fact that server push doesn’t really have a good way to consider the client’s existing cache…

Yeah i can see how that would be useful for dedicated css and js directories. Not sure if @matt would consider it.

True though Caddy can implement a browser cache aware conditional HTTP/2 server push like other web servers:

Yeah, that’s true. It’s complicated. Pull requests welcomed. :smiley:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.