Skip to content

no-cache option prevents preflight requests from being cached #5019

@pkuzco

Description

@pkuzco

In the current implementation of the matrix-js-sdk, setting the cache property of fetch() to no-cache (-> Cache-Control: max-age=0) prevents browsers from caching preflight (OPTIONS) requests. This behavior leads to unnecessary network overhead, as preflight requests are sent before every cross-origin request, even when the CORS policy remains unchanged.

https://github.com/matrix-org/matrix-js-sdk/blob/develop/src/http-api/fetch.ts#L294

The older implementation from 3 years ago doesn't seem to specify any cache-control directive on requests:
https://github.com/matrix-org/matrix-js-sdk/blob/e37aab29672256218d30876e96dd17fedc0506f7/src/http-api.ts

I'm not saying the new behavior is incorrect, but it's worth raising the issue and perhaps discuss it, as it has performance implications.

Image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions