question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

createObject does not set cacheControl

See original GitHub issue

Bug report

Describe the bug

TL;DR When I upload an object to storage via storage-js, the API doesn’t care about the cache-control value.

At the moment, when you call upload() from the Supabase client, it sets the default cache-control field to 3600 (https://github.com/supabase/storage-js/blob/main/src/lib/StorageFileApi.ts#L15). The API should take this field and set that as max-age (https://github.com/supabase/storage-api/blob/master/src/routes/object/createObject.ts#L59). If this value is not present, it is set to no-cache.

When I upload an object to a bucket, I can see that cache-control is set in the request (see screenshot below). This should mean that the server should respond with cache-control header value set tomax-age=3600 when I request for the object later on. image

However, when I download the object afterward, the header is set to no-cache. image

This is not desirable behavior, as we want to cache as many things as possible for a good user experience (and probably also lessen the load for Supabase too).

To Reproduce

  1. Using the supabase client, upload any object, with or without an optional cacheControl value set.
  2. Download the object using the supabase client, refresh the page after the download finishes.
  3. on refresh, check the network tab to see that (1) the browser requested and downloaded the object again (2) and the response has no-cache header set.

Expected behavior

Supabase API sets cache-control headers that we pass in.

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: Windows
  • Browser (if applies): chrome
  • Version of supabase-js: “1.7.7”,
  • Version of Node.js: v12.0.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
iniancommented, May 19, 2021

Can you try with supabase-js 1.11.14 James?

1reaction
horizon0708commented, May 19, 2021

It’s working! Thanks for a quick update! Looks like I was completely off the mark with https://github.com/supabase/storage-api/issues/18#issuecomment-843717897😅 image

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to make Microsoft XmlHttpRequest honor cache control ...
The W3C says that if there is a cache, it must honor Cache-Control if it is set through setRequestHeader . Microsoft's XmlHttpRequest doesn't...
Read more >
Client Cache <clientCache> - Microsoft Learn
The default is NoControl . Value, Description. NoControl, Does not add a Cache-Control or Expires header to the response.
Read more >
can't create object using REST - Backendless Support
I am using REST in Python 3.4 to create a data object in a table Latency. ... no-cache, must-revalidate, private < Cache-control: no-cache="set-cookie" ......
Read more >
Thread: [RESOLVED] How to disable cache in xmlhttprequest?
Hi, Private Function obj() As String Dim html As IXMLHTTPRequest Set html = CreateObject("Microsoft.XMLHTTP") With html .open "GET", ...
Read more >
PutObject - Amazon Simple Storage Service
You must have WRITE permissions on a bucket to add an object to it. Note. Amazon S3 never adds partial objects; if ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found