How to cache signed url for storage for specific path?

310 views Asked by At

I'm using signed url to generate session uri for resumable upload to gcp storage bucket. The flow is following

  1. client performs request to the backend, which generates signed url for post request, which is meant to be used to start resumable upload session
  2. backend generates signed url and returns it to client
  3. client sends post request to the url to start resumable upload session
  4. client receives session uri in response and starts uploading large file in multiple chunks (performs multiple put requests to the session uri)

Now the problem is following: during upload client refreshes page and tries to upload a file again. It should start from the last persisted chunk, but as after refresh client asks again backend about signed url, new signed url is being generated by backend, so upload starts from the beggining.

Is there any way to automatically cache signed urls, so for exmaple on backend site, when request for specific path in storage is being performed, I can resuse previous signed url (as long as it's still valid)? Of course I can cache it manually, but I am wondering if there is a way to do it automatically? For example to have always only one valid signed url for specific path in storage?

0

There are 0 answers