0

有没有人对 Windows azure 上的缓存控制有一些经验。我只是无法让它工作。我有一个 JSON 文件,我想要一些缓存规则。我有以下代码:

            var matchContainer = _blobClient.GetContainerReference(match.ClassContainer);
            matchContainer.CreateIfNotExists();
            matchContainer.SetPermissions(new BlobContainerPermissions
                                            {
                                                PublicAccess = BlobContainerPublicAccessType.Blob
                                            });
            // save the blob into the blob service   
            string uniqueBlobName = string.Format("matchdata/" + match.KeyPath + ".json").ToLower();
            CloudBlockBlob blob = matchContainer.GetBlockBlobReference(uniqueBlobName);
            var matchString = match.ToString();
            MemoryStream stream = new MemoryStream();
            StreamWriter writer = new StreamWriter(stream);
            writer.AutoFlush = true;
            writer.Write(matchString);

            stream.Seek(0, SeekOrigin.Begin);
            blob.UploadFromStream(stream);
            blob.Properties.CacheControl = "max-age=3600, must-revalidate";
            blob.SetProperties();

这与此处的示例完全相同 设置 Cache-Control的示例

标题只是没有设置。希望你能帮忙。

4

1 回答 1

0

如果您在 Windows 8.1 预览版上使用小提琴,我注意到它并不总是命中缓存。我不得不使用 chrome 来验证我的博客文章的缓存命中。

亚历克斯

于 2013-08-12T05:07:11.763 回答