Skip to content

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

fixed conflicts

fenosae7c8c5c41af
diff --cc apps/docs/pages/guides/storage/cdn.mdx
index bac2f3d9fc4,03bb1989db9..f0b23340130
--- a/apps/docs/pages/guides/storage/cdn.mdx
+++ b/apps/docs/pages/guides/storage/cdn.mdx
@@@ -36,6 -40,6 +42,7 @@@ Note that CDNs might still evict your o
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
<Admonition type="note">
@@@ -48,17 -53,13 +56,15 @@@ Additionally, the smart CDN has a highe
### Cache duration
- The Smart CDN cache duration is controlled on the server and cached for as long as possible. However, you can still control the browser caching TTL using the [cacheControl](/docs/reference/javascript/storage-from-upload) option when uploading a file. Smart CDN caching works with all types of operations including signed URLs.
+ When Smart CDN is enabled, the asset is cached on the CDN for as long as possible. You can still control how long assets are stored in the browser using the [cacheControl](/docs/reference/javascript/storage-from-upload) option when uploading a file. Smart CDN caching works with all types of storage operations including signed URLs.
When a file is updated or deleted, the CDN cache is automatically invalidated to reflect the change (including transformed images).
- It can take **up to 60 seconds** for the CDN cache to be invalidated as it has to propagate across all the data-centers around the globe.
+ It can take **up to 60 seconds** for the CDN cache to be invalidated as the asset metadata has to propagate across all the data-centers around the globe.
- When an asset is invalidated at the CDN level, it doesn't affect browser caching.
- If you don't see the changes, make sure the browser cache has been updated.
+ When an asset is invalidated at the CDN level, browsers may not update its cache.
-If your asset is updated frequently, we recommend setting a lower value using the `cacheControl` option even when using smart CDN.
+
+If your asset is updated frequently, we recommend that you re-upload the new asset in a different key, this way you'll always have the latest changes available without waiting the propagation delay.
- If your expect your asset to be deleted, we recommend setting a low browser TTL value using the `cacheControl` option when using smart CDN caching, the default is 1hour which generally is a good default.
-
++If you expect your asset to be deleted, we recommend setting a low browser TTL value using the `cacheControl` option when using smart CDN caching, the default is 1 hour which generally is a good default.
## Public vs Private Buckets
diff --cc apps/docs/pages/guides/storage/image-resizing.mdx
index 10cc6eef6e3,cdfbfd3a729..0d949925c52
--- a/apps/docs/pages/guides/storage/image-resizing.mdx
+++ b/apps/docs/pages/guides/storage/image-resizing.mdx
@@@ -59,48 -59,6 +59,48 @@@ supabase.storage.from('bucket').downloa
})
```
- ## Next JS Loader
++## NextJS Loader
+
+You can use Supabase Image Transformation to optimise your NextJS images using a custom [Loader](https://nextjs.org/docs/api-reference/next/image#loader-configuration).
+
+To get started, create a `supabase-image-loader.js` file in your NextJS project which exports a default function:
+
+```ts
+const projectId = '' // your supabase project id
+
+export default function supabaseLoader({ src, width, height, quality }) {
+ return `https://${projectId}.supabase.co/storage/v1/${src}?width=${width}&height=${height || 0}&quality=${quality || 75}`
+}
+```
+
+In your `nextjs.config.js` file add the following configuration to instruct NextJS to use our custom loader
+
+```js
+module.exports = {
+ images: {
+ loader: 'custom',
+ loaderFile: './supabase-image-loader.js',
+ },
+}
+```
+
+At this point you are ready to use the `Image` component provided by NextJS
+
+```tsx
+import Image from 'next/image'
+
+const MyImage = (props) => {
+ return (
+ <Image
+ src="bucket/image.png"
+ alt="Picture of the author"
+ width={500}
+ height={500}
+ />
+ )
+}
+```
+
## Transformation options
We currently support a few transformation options focusing on resizing and cropping images.