【问题标题】:Set cache header of Image when upload to Azure Storage using Python使用 Python 上传到 Azure 存储时设置图像的缓存标头
【发布时间】:2015-12-30 02:50:20
【问题描述】:

我正在将文件上传到 Azure 存储容器,需要设置缓存规则。本质上,我希望浏览器永远缓存它(或者只要浏览器选择)。

我正在从这里查看 x_ms_blob_cache_control:

https://msdn.microsoft.com/en-us/library/azure/ee691966.aspx

但是,他们没有说明值应该具有什么格式。我试过了

"max-age:31536000"
"max-age=31536000"

我正在通过 Python 上传:

import azure
from azure.storage.blob import BlobService

blob_service.put_block_blob_from_path(
        container_name = container_name,
        blob_name = blob_name ,
        file_path = file_path ,
        x_ms_blob_content_type = mime_type,
        x_ms_blob_cache_control = "WHAT GOES HERE?"
    )

每次我在浏览器中输入图片的网址以查看图片时,都会下载图片。

【问题讨论】:

    标签: python azure azure-storage


    【解决方案1】:

    没关系。我使用时它确实有效:

    "max-age=31536000"
    

    当我仅在 Chrome 中加载图像(地址栏中的图像 url)时,它不会缓存它。但是,当我在网页中使用它作为 img src 时,它被缓存了。

    如果其他人有类似的问题,我会留下这个。

    【讨论】:

      猜你喜欢
      • 2020-01-09
      • 2017-02-12
      • 1970-01-01
      • 2021-06-01
      • 2014-08-18
      • 1970-01-01
      • 2018-12-17
      • 1970-01-01
      • 2014-07-22
      相关资源
      最近更新 更多