Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

docs: rebase master

fenose0348cf8a625
diff --cc apps/docs/components/Navigation/Navigation.constants.ts
index 8af16004887,5db85450719..fb7ddbfeb64
--- a/apps/docs/components/Navigation/Navigation.constants.ts
+++ b/apps/docs/components/Navigation/Navigation.constants.ts
@@@ -245,8 -245,9 +245,10 @@@ export const menuItems: NavMenu =
label: 'Storage',
items: [
{ name: 'Overview', url: '/guides/storage', items: [] },
- { name: 'CDN', url: '/guides/storage-cdn', items: [] },
+ { name: 'Quickstart', url: '/guides/storage/quickstart', items: [] },
+ { name: 'Access Control', url: '/guides/storage/access-control', items: [] },
+ { name: 'CDN', url: '/guides/storage/cdn', items: [] },
+ { name: 'Image Resizing', url: '/guides/storage/image-resizing', items: [] },
],
},
{
diff --cc apps/docs/pages/guides/storage/cdn.mdx
index a93ab8b2f09,1d5023c7dc0..d850051e9cb
--- a/apps/docs/pages/guides/storage/cdn.mdx
+++ b/apps/docs/pages/guides/storage/cdn.mdx
@@@ -7,55 -7,22 +7,64 @@@ export const meta =
sidebar_label: 'CDN',
}
- ## CDN basics
+ All assets uploaded to Supabase Storage are cached on a Content Delivery Network (CDN) to improve the latency for users all around the world. CDNs are a geographically distributed set of servers or **nodes** which caches content from an **origin server**. For Supabase Storage, the origin is the storage server running in the [same region as your project](https://app.supabase.com/project/_/settings/general). Aside from performance, CDNs also help with security and availability by mitigating Distributed Denial of Service and other application attacks.
- All assets uploaded to storage are cached on a Content Delivery Network (CDN).
-## Example
++## Basic CDN - TTL Caching
- To improve the latency for users all around the world, Supabase uses a CDN. CDNs are a geographically distributed set of servers or **nodes** which caches content from an **origin server**. For Supabase Storage, the origin is the storage server running in the [same region as your project](https://app.supabase.com/project/_/settings/general).
-Let’s walk through an example of how a CDN helps with performance. A new bucket is created for a Supabase project launched in Singapore. All requests to the Supabase Storage API first hit the CDN. A user from the United States requests an object and is routed to the U.S. CDN. At this point, that CDN node does not have the object in its cache and pings the origin server in Singapore. Another user, also in the United States, requests the same object and is served directly from the CDN cache in the United States instead of routing the request back to Singapore.
++### Example
- Let’s walk through an example of how a CDN helps with performance. A new bucket is created for a Supabase project launched in Singapore. All requests to the Supabase Storage API first hit the CDN. A user from the United States requests an object and is routed to the U.S. CDN. At this point, that CDN node does not have the object in its cache and pings the origin server in Singapore. Another user, also in the United States, requests the same object and is served directly from the CDN cache in the United States instead of routing the request back to Singapore.
-## Cache duration
++Let’s walk through an example of how a CDN helps with performance.
- Aside from performance, CDNs also help with security and availability by mitigating Distributed Denial of Service and other application attacks.
-By default, assets are cached both in the CDN and in the user's browser for 1 hour. After this, the CDN nodes ping the storage server to see if an object has been updated. You can modify this cache time when you are [uploading](/docs/reference/javascript/storage-from-upload) or [updating](/docs/reference/javascript/storage-from-update) an object by modifying the `cacheControl` parameter. If you expect the object to not change at a given URL, setting a longer cache duration is preferable.
++A new bucket is created for a Supabase project launched in Singapore. All requests to the Supabase Storage API first hit the CDN.
- ## Cache duration
-If you need to update the version of the object stored in the CDN, there are various cache-busting techniques you can use. The most common way to do this is to add a version query parameter in the URL. For example, you can use a URL like `/storage/v1/object/sign/profile-pictures/cat.jpg?token=eyJh...&version=1` in your applications and set a long cache time of 1 year. When you want to update the cat picture, you can increment the version query parameter in the URL. The CDN will treat `/storage/v1/object/sign/profile-pictures/cat.jpg?token=eyJh...&version=2` as a new object and pings the origin for the updated version.
++A user from the United States requests an object and is routed to the U.S. CDN. At this point, that CDN node does not have the object in its cache and pings the origin server in Singapore. Another user, also in the United States, requests the same object and is served directly from the CDN cache in the United States instead of routing the request back to Singapore.
+
- By default, assets are cached both in the CDN and in the user's browser for 1 hour. After this, the CDN nodes ping the storage server to see if an object has been updated.
++### Cache duration
+
- You can modify this cache time when you are [uploading](/docs/reference/javascript/storage-from-upload) or [updating](/docs/reference/javascript/storage-from-update) an object by modifying the `cacheControl` parameter.
++By default, assets are cached both in the CDN and in the user's browser for 1 hour.
+
++After this, the CDN nodes ping the storage server to see if an object has been updated. You can modify this cache time when you are [uploading](/docs/reference/javascript/storage-from-upload) or [updating](/docs/reference/javascript/storage-from-update) an object by modifying the `cacheControl` parameter.
+If you expect the object to not change at a given URL, setting a longer cache duration is preferable.
+
- If you need to update the version of the object stored in the CDN, there are various cache-busting techniques you can use. The most common way to do this is to add a version query parameter in the URL. For example, you can use a URL like `/storage/v1/object/sign/profile-pictures/cat.jpg?token=eyJh...&version=1` in your applications and set a long cache time of 1 year. When you want to update the cat picture, you can increment the version query parameter in the URL. The CDN will treat `/storage/v1/object/sign/profile-pictures/cat.jpg?token=eyJh...&version=2` as a new object and pings the origin for the updated version.
++If you need to update the version of the object stored in the CDN, there are various cache-busting techniques you can use.<br /> The most common way to do this is to add a version query parameter in the URL.
++
++For example, you can use a URL like `/storage/v1/object/sign/profile-pictures/cat.jpg?token=eyJh...&version=1` in your applications and set a long cache time of 1 year.
++
++When you want to update the cat picture, you can increment the version query parameter in the URL. The CDN will treat `/storage/v1/object/sign/profile-pictures/cat.jpg?token=eyJh...&version=2` as a new object and pings the origin for the updated version.
Note that CDNs might still evict your object from their cache if it has not been requested for a while from a specific region. For example, if no user from United States requests your object, it will be removed from the CDN cache even if you set a very long cache control duration.
The cache status of a particular request is sent in the `cf-cache-status` header. A cache status of `MISS` indicates that the CDN node did not have the object in its cache and had to ping the origin to get it. A cache status of `HIT` indicates that the object was sent directly from the CDN.
+
+## Smart CDN Caching
+
+With Smart CDN caching enabled, we are synchronizing the asset metadata (not the content) that live in your database to the edge.
+By doing this we are able to automatically revalidate the cache when the content of an asset changes or gets deleted.
+
+On top of automatic revalidation, you will also benefit from a much greater Cache HIT ratio, since we are able to shield the origin server when
- requesting an asset that hasn't changed with a different query string url.
++requesting an asset that hasn't changed when using different query string url.
++
++<Admonition type="note">
++ Smart CDN caching is enabled for PRO tiers and above
++</Admonition>
+
+### Cache duration
+
+When using Smart CDN, we will control the CDN cache duration on the server and caching it for as long as possible.
+However, you are still in control of the browser caching TTL which you can set by using the [cacheControl](/docs/reference/javascript/storage-from-upload) option while uploading the file.
+
+When a file is updated or deleted, we will automatically invalidate the CDN cache to reflect the change as well as to all derivatives (transformed images).
+Keep in mind that the invalidation can take <b>up to 60 seconds</b> to be propagated across all the data-centers across the globe.
+
+When we invalidate an asset at the CDN level, it can't, doesn't, affect browser caching.
+If you don't see the reflected changes make sure the browser cache has been updated.
+
+If your asset is updated frequently we recommend setting a low browser ttl value using the `cacheControl` option when using smart cdn caching.
+
+Smart CDN caching works with all types of operations including signed urls.
+
+
## Public vs Private Buckets
Objects in public buckets do not require any Authorization to access objects. This leads to a better cache hit rate compared to private buckets. For private buckets, permissions for accessing each object is checked on a per user level. For example, if two different users access the same object in a private bucket from the same region, it results in a cache miss for both the users since they might have different security policies attached to them. On the other hand, if two different users access the same object in a public bucket from the same region, it results in a cache hit for the second user.
diff --cc apps/docs/pages/guides/storage/image-resizing.mdx
index be5219d2ea8,00000000000..31c28cbe364
mode 100644,000000..100644
--- a/apps/docs/pages/guides/storage/image-resizing.mdx
+++ b/apps/docs/pages/guides/storage/image-resizing.mdx
@@@ -1,120 -1,0 +1,118 @@@
+import Layout from '~/layouts/DefaultGuideLayout'
+
+export const meta = {
+ id: 'storage-image-resizing',
+ title: 'Storage Image Resizing',
+ description: 'Resize images with Storage',
+ sidebar_label: 'Image Transformation',
+}
+
+Supabase Storage offers the functionality to transform and resize images dynamically. Any image stored in your buckets can be transformed and optimized for fast delivery.
+
+<Admonition type="note">
- Image Resizing is enabled for PRO tiers and above
++ Image Resizing is currently in beta and enabled for PRO tiers and above
+</Admonition>
+
+### Get a public URL for a Transformed image
+
+You can pass a `transform` option to the functions you are currently using to interact with your objects. This returns the public URL that serves the resized image.
+
+```ts
+supabase.storage.from('bucket').getPublicUrl('image.jpg', {
+ transform: {
+ width: 500,
+ height: 600,
+ }
+})
+```
+
- This will return the public URL with the formatted transformation parameters.
- Once visited you’ll be served with the resized image
-
+An example URL could look like this:
++
+`https://project_id.supabase.co/storage/v1/render/image/public/bucket/image.jpg?width=500&height=600`
+
+
+### Signing URLs - With transformation options
+
+To share a transformed image for a fixed amount of time, provide the transform options when you create the signed URL:
+
+```ts
+supabase.storage.from('bucket').createSignedUrl('image.jpg', 60000, {
+ transform: {
+ width: 200,
+ height: 200,
+ }
+})
+```
+
+The transformation options are embedded into the token, they cannot be changed once signed.
+
- ## Downloading Images
++### Downloading Images
+
+To download a transformed image, pass the `transform` option to the `download` function
+
+```ts
+supabase.storage.from('bucket').download('image.jpg', {
+ transform: {
+ width: 800,
+ height: 300,
+ }
+})
+```
+
- ### Transformation options
++## Transformation options
+
+We currently support a few transformation options focusing on resizing & cropping.
+We have plans to increase the transformation types available in a later release.
+
+### Resizing
+
+You can use `width` and `height` parameters to resize an image to a specific dimension. If only one parameter is specified, the image will be resized and cropped, maintaining the aspect ratio.
+
+### Modes
+
+You can use different resizing modes to fit your needs, each of them uses a different approach to resize the image:
+
+Use the `resize` parameter with one of the following values:
+
+- `cover` : resizes the image while keeping the aspect ratio to fill a given size and crops projecting parts. (default)
+
+- `contain` : resizes the image while keeping the aspect ratio to fit a given size.
+
+- `fill` : resizes the image without keeping the aspect ratio.
+
+Example:
+
+```ts
+supabase.storage.from('bucket').download('image.jpg', {
+ transform: {
+ width: 800,
+ height: 300,
+ resize: 'contain' // 'cover' | 'fill'
+ }
+})
+```
+
+### Limits
+
+- Width and height must be an integer value between 1-2500.
+- The image size cannot exceed 25MB.
+- The image resolution cannot exceed 50MP.
+
+### Supported Image Formats
+
+| Format | Extension | Source | Result |
+| -------|-----------|--------|--------|
- | PNG | `png` | Yes | Yes |
- | JPEG | `jpg` | Yes | Yes |
- | WebP | `webp` | Yes | Yes |
- | AVIF | `avif` | Yes | Yes |
- | GIF | `gif` | Yes | Yes |
- | ICO | `ico` | Yes | Yes |
- | SVG | `svg` | Yes | Yes |
- | HEIC | `heic` | Yes | No |
- | BMP | `bmp` | Yes | Yes |
- | TIFF | `tiff` | Yes | Yes |
++| PNG | `png` | ☑️ | ☑️ |
++| JPEG | `jpg` | ☑️ | ☑️ |
++| WebP | `webp` | ☑️ | ☑️ |
++| AVIF | `avif` | ☑️ | ☑️ |
++| GIF | `gif` | ☑️ | ☑️ |
++| ICO | `ico` | ☑️ | ☑️ |
++| SVG | `svg` | ☑️ | ☑️ |
++| HEIC | `heic` | ☑️ | ❌ |
++| BMP | `bmp` | ☑️ | ☑️ |
++| TIFF | `tiff` | ☑️ | ☑️ |
+
+export const Page = ({ children }) => <Layout meta={meta} children={children} />
+
+export default Page
diff --cc apps/www/pages/storage/Storage.tsx
index a473e23cd3e,a473e23cd3e..f9934a488b3
--- a/apps/www/pages/storage/Storage.tsx
+++ b/apps/www/pages/storage/Storage.tsx
@@@ -194,7 -194,7 +194,7 @@@ function StoragePage()
title="Transformations"
text="Resize and compress your media before you serve it."
/>
-- <Badge>Coming soon</Badge>
++ <Badge>New</Badge>
</div>
</div>,
]}