Closed Soetens closed 8 months ago
Wsrv is great and can work as a CDN because it is behind Cloudflare, but using a relative path to your image would not reduce your bandwidth, at least not more than running just CloudFlare.
However, I am having troubles understanding. Did you mean locally on the users' devices or on your website? Assuming you mean the latter, I'd like to know if you are aware that /images/photo.jpg and https://domain.com/images/photo.jpg both serve from the same webserver in case you are on domain.com.
Do you instead mean a local path on wserv.nl's servers? They are a simple service for processing photos on-the-fly that does provide caching. If you plan to use wsrv.nl purely to minimize server bandwidth, maybe instead put them in a Github repo and use something like Cloudflare Pages to serve them, meaning you won't even have to save them on your server. They provide unlimited bandwidth for static files, and may suite your use-case better.
Wsrv is to my understanding mainly used to transform images based on client-side conditions (such as screen size), not mainly to safe webserver bandwidth.
If I am misunderstanding your request, please write to me to elaborate.
Kindly, Jonte.
If you host the code yourself, this would be possible by configuring the module as filter. See: https://github.com/weserv/images/tree/5.x/ngx_conf#weserv
In this way you are able to pass static files, instead of using the ?url= parameter.
We have a demo for this on the public service. https://github.com/weserv/images/blob/ca63088b93de7501eeb5d9f298380e36162b566f/ngx_conf/imagesweserv.conf#L77-L81
If you for example have this image: https://images.weserv.nl/logo.svg
You can resize it using the /static/ prefix, like this: https://images.weserv.nl/static/logo.svg?w=100
Is that what you want?
Sorry that my question was not very clear, it's the self hosted solution.
For example, this is 2 webserver requests:
https://mydomain.nl/?url=mydomain.nl/transparency_demo.png&w=400&bg=black
But I would like something like
https://mydomain.nl/?path=transparency_demo.png&w=400&bg=black
So it will get the data directly from the filesystem and needs less requests to the webserver.
In that case try https://mydomain.nl/static/transparency_demo.png?w=400&bg=black
. That should work out of the box.
The /static/
is a virtual path to /
using the weserv filter
mode, as stated in my previous reply.
Oh, sorry, I must've misunderstood!
I hope this information helped. Please feel free to re-open if questions remain.
Is it possible to use a local or absolute path, eg
/images/photo.jpg
, in stead ofssl://domain.com/images/photo.jpg
? So we don't need to use (and overload) de webservers while its not needed.