storage icon indicating copy to clipboard operation
storage copied to clipboard

fix: use correct format for last modified date header

Open ikhsan opened this issue 2 years ago • 0 comments

What kind of change does this PR introduce?

bug fix

What is the current behavior?

Browser (or other client) never cache the images from storage: https://github.com/supabase/storage-api/issues/193

What is the new behavior?

When setting the last-modified header, use toUTCString to ensure the date format adheres to the rfc2616 spec

Additional context

  • I learned that all of these response headers are not yet tested (eg all tests are passing even after I removed all of these lines). This PR mocks the request headers and asserts the response headers https://github.com/supabase/storage-api/blob/6e2ae7a521db22af37f8d612cdfab6ad00ca4c9f/src/routes/object/getObject.ts#L81-L85

  • For running the tests multiple times, it seemed that we can't run them without restarting the whole container. Running jest twice failed for me because I think there is no resets between tests. I ended up running the tests one-by-one as I am only interested on the GET requests, so running them multiple times is fine as it doesn't change the db.

  • The fix might be premature as I haven't actually confirmed the bug yet. Please check and respond to the filed issue. Happy to close the PR if turns out that it's not an actual bug, happy to be corrected or improved if the bug is valid 👍

ikhsan avatar Sep 19 '22 06:09 ikhsan