質問

What is the correct setup for caching response header with more than one dispatchers behind a loadbalancer?

I want to send ETag or Last-Modified header with dispatcher, but there is no synchronization between dispatcher instances, so the modification date of the same page will be different in the cache of the dispatchers.

What is the right solution for this?

Maybe "FileETag Size" would cause the same ETag on all dispatcher instances, but I hope there is a better solution.

Thanks!

役に立ちましたか?

解決

If you look at an image on the geometrixx sample app, you will see that the epoch is written in as a suffix at the end of the path to the component instance by CQ5. i.e. /content/geometrixx/mypage/_jcr_content/mycomponent/myimg.img.jpg/1397355982.jpg

You can make your component in a similar way, and thus, you don't have to rely upon the headers themselves.

If you are using an edge caching solution such as F5, the modified epoch is generally not used, but rather an MD5 of the byte data of the image. This way, it is only when the content itself varies that the client side will be instructed to fetch a new image.

FileETag Size would also not be 100%, as you are expecting the file to differ in number of bytes. It does work relatively OK with lossy web image algorithms etc, as the file size will vary with an edit of the file.

The only thing to keep in mind is how fast your edge cache solution is at regenerating the etags. We have found that F5 with web accelerator does a great job of this. This technique allows you to cache forever, heavily reducing the load on your servers, especially if you don't have a limitless pipe and recurring images at the front across pages that are hit over a longer period of time.

It is also worthwhile looking into some of the more clever solutions that leverage HTML5 client side caching techniques for mobile devices when they are detected, as cache forever works much better on a desktop than a mobile device at this stage, as the cache is much smaller on mobiles.

Hope that helps a bit.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top