Adding a Google Cloud Storage Source
A Google Cloud Storage Source connects to an existing Google Cloud Storage bucket. imgix connects using the credentials you supply, so assets don’t have to be public. Visit the Interoperability tab for your Google Cloud Storage project and create an access key/secret pair to use with imgix.
Setting Cache-Control Headers for Google Cloud Storage
Google Cloud Storage applies Cache-Control: no-store, no-cache, max-age=0, must-revalidate
headers in the absence of a Cache-Control
header on your asset files, disabling any possibility of caching. Because of this, imgix defaults the Cache TTL Behavior mode in Advanced Source Settings for all new Google Cloud Storage Sources to “Enforce minimum”, which applies max-age=1yr, public
to all files whether they have a header or not. This is to ensure that caching works on all files.
If you have already set Cache-Control
headers on your asset files, you should change the Cache TTL Behavior setting to “Respect origin” after you set up your Source. If you have not set headers, we recommend leaving it set to “Enforce minimum”.
Setting Up Your Google Cloud Storage Source
-
Go to the Sources page in the imgix dashboard and click the New Source button.
-
Select Google Cloud from the How do you store your media? radio options.
-
Fill in the details of your Google Cloud Storage Source.
Note: We strongly recommend creating a set of access keys specifically for imgix to access your bucket with. Keep in mind that imgix only requires Read
and List
permissions to begin serving your assets. For more information on how to generate your Access Key and Secret Access Key or where to find your Bucket Name see the Google Cloud Storage Guide documentation.
- Access Key: The Interoperable access key of the
deployment_credentials
for your project. - Secret Key: The secret key of the
deployment_credentials
you want imgix to connect with. - Bucket Name: The name of the bucket within the project where your assets are stored.
- Path Prefix (optional): The subfolder prefix you want to resolve to (if it exists). The prefix is prepended to the asset path before resolving the asset in Google Cloud Storage. By default the asset path is
/
.
- Name the Subdomain you’d like to use as the base URL for your assets.
Note: The subdomain name you choose is unique to your Source and can’t be re-used. If you’re setting up a Source with a lot of customization (particularly a Custom Domain), choose the name you plan to use going forward.
- If you are editing an existing Source and the Video API is enabled, the imgix Video Subdomain field will be visible. This field automatically inherits the value from your imgix Image Subdomain and cannot be modified without changing the Image Subdomain.
- Click the Deploy Source button on Step #3 to queue your Source for deployment.
Google Cloud Storage Guide
We strongly recommend creating a set of access keys specifically for imgix to access your bucket with.
GCS bucket location
At this time, we recommend us-central-1 as the bucket location to reduce your egress costs and performance when imgix fetches assets from your bucket. This recommendation is subject to change in the future.
Advanced Settings
See the Advanced Source Settings for information about setting up custom domains, defaults, and cache TTL options.
Uploading
To upload images and videos directly to your cloud-storage-backed Google Cloud Storage Source, you will have to create a separate set of upload_credentials
. To upload to your Source directly through Asset Manager, you will also have to update your bucket’s CORS configuration. Uploading should only be set up post-Source-deployment.
imgix’s rendering service does not need Write
permissions to fetch assets; therefore, we highly recommend that you do not use the same credentials for your upload_credentials
and your deployment_credentials
.