关于使用amazone的cloudfront
cloudfront类似于CDN,文件存储在S3上,cloudfront的各个edge从S3上抓取文件,最终客户端按照地理位置的最近原则访问cloudfront的某个edge,cloudfront每24小时从S3上抓取一次文件,这个时间不能减小,如果你修改了S3上的文件,那么,你需要等24小时,cloudfront才会更新该文件,amazon推荐使用object version命名方法来为文件命名:
We recommend that you use the common technique of versioning to give yourself better control of your content. Versioning means that you assign each object in the origin server a version number. For example, instead of calling the file
image.jpg
, you call it image_1.jpg
. Then when you want to start serving a new version of the file, you name that new file image_2.jpg
, and you update your links to point to image_2.jpg
. With versioning, you do not have to wait for an object to expire before you can serve a new version of it.
。
你可以为上传到S3上的文件设置http的header,如Cache-Control,等。
如果网站的国外访问量不是很大,完全可以将文件放到S3上,然后在国内建立squid来缓存S3上的文件。