caddyserver / cache-handler

Distributed HTTP caching module for Caddy
Apache License 2.0
235 stars 17 forks source link

Last-Modified header and cache skip #69

Open fliespl opened 6 months ago

fliespl commented 6 months ago
    @cacheable_sitemap {
       path_regexp "^/([a-z0-9-]+-sitemap([0-9]+)?|sitemap_index)\.xml"
    }

    header @cacheable_sitemap {
        -Last-Modified
        +X-Sitemap 1
    }

    cache @cacheable_sitemap {
        cache_name sitemap
        key {
            disable_method
            disable_query
        }
        mode bypass
        ttl 300s
    }

I would like to use such rules to cache sitemap files.

Unfortunately, no matter what I do Last-modified header is still returned to the client and subsequent requests have If-Modified-Since set making souin to request backend due to: detail=REQUEST-REVALIDATION. For test purposes I have added X-Sitemap one and it gets appended.

I have also tried request_header matcher to remove "if-modified-since" but I guess it executes after cache part.

Any ideas? :)