CDN is mainly used to accelerate static resources, and dynamic resources will be returned to the source site for real-time acquisition without caching. The cache expiration time for a resource can be set up to a maximum of 3 years depending on the file type and update frequency.

CDN provides refresh and warm-up functions for resources. With the refresh function, you can force the CDN node to go back to the source and get the latest file; Through the preheating function you can preheat hot resources before the business peak, improve the efficiency of resource access.

Refresh function means that the cache contents of the CDN node will be forced to expire after the request of URL refresh or directory refresh is submitted. When you request resources from the CDN node, the CDN will directly go back to the source station to obtain the corresponding resources and return them to you and cache them. The refresh feature reduces the cache hit rate.

The call interface refreshes the file contents on the node. Flushed file cache will be immediately invalidated, new requests will go back to the source to get the latest file, support URL batch refresh.

The command line refreshes the script

<? php include __DIR__ . '/vendor/autoload.php'; use AlibabaCloud\Client\AlibabaCloud; use AlibabaCloud\Client\Exception\ClientException; use AlibabaCloud\Client\Exception\ServerException; / / Download:https://github.com/aliyun/openapi-sdk-php / / the Usage: https://github.com/aliyun/openapi-sdk-php if (count($argv) ! = 2) {echo "parameter error "; exit; } $accessKeyId = '<accessKeyId>'; $accessSecret = '<accessSecret>'; $project = $argv[1]; $path = "https://www.yourdomain.com/{$project}/"; AlibabaCloud::accessKeyClient($accessKeyId, $accessSecret) ->regionId('cn-qingdao') ->asDefaultClient(); try { $result = AlibabaCloud::cdn() ->v20180510() ->refreshObjectCaches() ->withObjectType("Directory") ->withObjectPath($path) ->withSecurityToken($accessKeyId) ->debug(true) // Enable the debug will output detailed information ->request(); print_r($result->toArray()); } catch (ClientException $e) { print_r($e->getErrorMessage()); } catch (ServerException $e) { echo $exception->getMessage() . PHP_EOL; echo $exception->getErrorCode() . PHP_EOL; echo $exception->getRequestId() . PHP_EOL; echo $exception->getErrorMessage() . PHP_EOL; }

Reference:

Configure the cache expiration time

Configure refresh and warm-up

Call the API to refresh the file contents on the node