Welcome to OGeek Q&A 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...