如何从 Azure 存储 CDN https `GET` 文件的新副本?

问题描述 投票:0回答:0

基本上,我想在天蓝色存储 CDN 的开发过程中

GET
https 一个新副本。 但我不想等待 20 小时让 CDN 重新水化。

我尝试添加标题

Cache-control: no-cache, no-store, must-revalidate
但没有成功。

我的文件具有如下

Cache-control: no-cache, no-store, must-revalidate
属性:

奇怪的是,当我从我的 Macbook Pro 的 Chrome 或 Safari

GET
时,我得到了最新的(新鲜)版本,而当我从基于 ESP32 的自定义 PCB 通过相同的 SSID WiFi 执行
GET
时,我得到了旧版本。

我的代码如下:

/// @brief Writes the GET on [path] and write mandatory constant headers
/// @param host The host name
/// @param path The path of he document to get
static void httpsGetWriteMandatoryHeaders(char const *hostname, char const * path) {
    client.printf("GET %s HTTP/1.1", path);             client.println();
    client.printf("Host: %s", hostname);                client.println();

    client.printf("Accept-encoding: gzip, deflate");    client.println();
    client.printf("Cache-control: no-cache, no-store, must-revalidate"); client.println();
    client.print ("Accept-encoding: gzip, deflate");    client.println();
}

bool NanoWifi :: httpsGet(
    char const *hostname, char const *path, 
    byte *buffer, size_t bufferCapacity, 
    size_t &bodyLength, bool &bufferOverflows,
    void (*downloadChunkCallback)(byte * buffer, size_t bufferReadCount, size_t contentLength),
    bool verbose
    ) {

    log("Time is: %d %d %d %02d:%02d:%02d", day(), month(), year(), hour(), minute(), second());

    char const * subModule = "httpsGet: ";
    
    if (verbose) log("%sbegin %s%s…",subModule, hostname, path);
    
    // === if you get a connection, report back via serial:
    if (!client.connect(hostname, 443)) {
        // if you didn't get a connection to the server:
        error("%sconnection failed", subModule);
        return false;
    }

    unsigned chunkIndex = 0;

    success("%sConnected!",subModule);

    // Make a HTTP request:
    httpsGetWriteMandatoryHeaders(hostname, path);

    client.printf("Range: bytes=%d-%d", chunkIndex*bufferCapacity, (chunkIndex+1)*bufferCapacity);              client.println();
    client.println();


// etc.

请注意,我使用

Range:
标头来获取小块,因为我没有足够的内存来获取更大的固件文件块。但我认为这对我的缓存问题没有影响。

关于我应该如何做

GET
的任何想法?

顺便说一句,这里是你想自己尝试时获取的 URL:https://blobs.olenpeps.com/sbm/firmwares/cache.test.bin

c++ azure http cache-control azure-cdn
© www.soinside.com 2019 - 2024. All rights reserved.