Skip to content

Course images can't be cached by the browser #677

@leonstr

Description

@leonstr

For the My courses (my/courses.php) page, there's a request to load an image, for example, GET pluginfile.php/7565598/course/overviewfiles/Clipboard01.jpg, which gets a 303 response redirecting to:

https://[site].s3.eu-west-2.amazonaws.com/2f/11/2f11a9...?response-content-disposition=inline%3B%20filename%3D%22Clipboard01.jpg%22&response-content-type=image%2Fjpeg&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=...&X-Amz-Date=20250327T152617Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3583&X-Amz-Signature=9d0...159

If I then refresh the page the 303 redirects to:

https://[site].s3.eu-west-2.amazonaws.com/2f/11/2f11a9...?response-content-disposition=inline%3B%20filename%3D%22Clipboard01.jpg%22&response-content-type=image%2Fjpeg&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=...&X-Amz-Date=20250327T153442Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3558&X-Amz-Signature=9d3...95d

a different URL. The browser doesn't have the payload for this new URL in it's cache so it fetches the image again despite it being identical.

Environment

Moodle 4.5.3+ (Build: 20250326)
tool_objectfs 2025031800
PHP version 8.2.27

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions