Alibaba Cloud OSS sets the cache time for pictures in batches

OSS settings cache

  由于我们的图片存在OSS上  程序上传图片的时候 未添加缓存效果。
  导致现在访问图片 都是新请求OSS的图片,导致流量拉满。

ossutil deployment and installation

Alibaba Cloud ossutils tool
ossutil is a command line tool to manage OSS data. It provides convenient, concise, and rich storage space (Bucket) and file (Object) management commands, and supports Windows, Linux, and Mac platforms.
With ossutil, you can perform the following operations:

  管理Bucket,如:创建、列举或删除Bucket等。
  管理Object,如:上传、下载、列举、拷贝和删除Object等。
  管理碎片(part),如:列举和删除part等。

OSS set cache header information

参考: https://help.aliyun.com/document_detail/31913.html?spm=5176.8466032.0.dexternal.569d1450jim1lr

Configuration file

./ossutil64 config
请输入配置文件名,文件名可以带路径(默认为:/home/user/.ossutilconfig,回车将使用默认路径。如果用户设置为其它路径,在使用命令时需要将--config-file选项设置为该路径): 
未输入配置文件路径,将使用默认配置文件:/home/user/.ossutilconfig。 
对于下述配置,回车将跳过相关配置项的设置,配置项的具体含义,请使用"help config"命令查看。
请输入语言(CH/EN,默认为:CH,该配置项将在此次config命令成功结束后生效):CH 
请输入endpoint:http://oss-cn-shenzhen.aliyuncs.com  #从OSS的Bucket概述里面获取 建议ECS使用内网地址
请输入accessKeyID:yourAccessKeyID     
请输入accessKeySecret:yourAccessKeySecret
请输入stsToken:  
endpoint acquisition
对应的Bucket里面的概述里面获取
accessKeyID and accessKeySecret acquisition

Alibaba Cloud OSS sets the cache time for pictures in batches

stsToken
非必配项,若采用STS临时授权方式访问OSS需要配置该项,否则置空即可

Set all files in the specified directory to be cached

./ossutil64 set-meta oss://Bucket/mg/  Cache-Control:max-age=604800 -r

Set the specified suffix file setting cache in the specified directory ( .png and .jpeg file setting cache)

./ossutil64 set-meta oss://Bucket/images --include "*.png"  --include "*.jpeg" -r Cache-Control:max-age=604800

Guess you like

Origin blog.51cto.com/9025736/2544664