Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

reverse proxy - varnish caching external content requested by backend url

I'm newbie to varnish. I want to to serve all the request from the varnish cache. My backend asked content from CDN and also from other location. Like

My varnish is example.com backend IP 123.123.123.123 backend url request abc.jpg with a link http://web.example.com/api/abc.jpg and some CDN content like https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js

Normally they are not being cached. Served directly to the client browser from their origin location. How to use varnish cache all of them and set a cache lifetime ?

Thanks in advance

question from:https://stackoverflow.com/questions/66054428/varnish-caching-external-content-requested-by-backend-url

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Varnish Cache uses static backends. You can define the backends explicitly for each external resource you need (web.example.com, cdnjs.cloudflare.com, ...). This has to happen ahead of time and cannot be done on-the-fly.

However, Varnish Enterprise, the commercial version of Varnish offers a module that supports dynamic backends. See https://docs.varnish-software.com/varnish-cache-plus/vmods/goto/ for more info.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...