开发者

Use server-side proxy to set expires header for static resources on another domain

开发者 https://www.devze.com 2023-01-19 17:26 出处:网络
I have a web app that links to several thumbnail images from another server on the same domain that I have no configuration control over.The page loads about about 2 to 2.5 mb worth of static images.I

I have a web app that links to several thumbnail images from another server on the same domain that I have no configuration control over. The page loads about about 2 to 2.5 mb worth of static images. I would really like to have the server owner set the expires header so the images don't re-download every single time, but unfortunately that's not possible.

I was considering implementing a very simple proxy that simply passes the data through and injects the expires header. My server would take an extra hit for each initial connection as all the images would be proxied, but after the first client load, the client should just use the cached images and all that bandwidth/load times would be spared.

It SEEMS like a logical thing to do, but I can't find anything anywhere that recomm开发者_JAVA百科ends it or find an example where somebody else does this. Is this a good idea?


It will work, but it's terrible.

I would recommend to just grab everything from that remote server (at once or on as-requested basis), and copy it to your server/3rd party CDN. So that you will have 1 request per image, not 1 per image/user.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号