darkweak / souin

An HTTP cache system, RFC compliant, compatible with @tyktechnologies, @traefik, @caddyserver, @go-chi, @bnkamalesh, @beego, @devfeel, @labstack, @gofiber, @go-goyave, @go-kratos, @gin-gonic, @roadrunner-server, @zalando, @zeromicro, @nginx and @apache
https://docs.souin.io
MIT License
714 stars 56 forks source link

Configurable HTTP status code list for isCacheableCode #574

Open patramsey opened 4 days ago

patramsey commented 4 days ago

Hello,

I have a use case where I would like to cache HTTP 301 and HTTP 302 responses. The list of cacheable response codes seems hard coded in isCacheableCode.

func isCacheableCode(code int) bool {
    switch code {
    case 200, 203, 204, 206, 300, 301, 404, 405, 410, 414, 501:
        return true
    }

    return false
}

I understand this list comes directly from the RFC . Would there be an appetite for a PR to make this list configurable for non standard use cases like mine?

darkweak commented 3 days ago

Hey @patramsey I can implement that in this tool, the PR should be ready on Monday. :)