Flush the CDN Cache¶
Overview¶
Stitch serves hosted files through a CDN in order to minimize the latency between receiving a request for a resource and returning the requested resource. When a client requests a resource that’s hosted in Stitch, the CDN server that processes the request checks for a cached copy of the file that it can return instead of requesting a new copy of the file from Stitch.
The CDN caching process decreases the latency for end users when they request a resource, but it can also prevent them from receiving the most up-to-date version of a resource if the file has changed since the CDN server cached it. You can invalidate all cached files to force the CDN servers to fetch new copies from Stitch.
To flush the CDN cache for all hosted files, select the tab below that corresponds to the interface you want to use and follow the procedure.
Note
You can configure the caching behavior for an individual file by adding a a Cache-Control attribute to the file.
Procedure¶
- Stitch UI
- Import/Export
Select the Purge Cache Action¶
You can purge the cache for all hosted files from the Files tab.
- Click the Actions button above the list of files.
- Click Purge Cache.
- In the Purge Cache modal, click Confirm.
Select the Attribute Type and Value¶
The new metadata attribute will not have a type or value when you first add it.
- Select the attribute type from new attribute’s left-hand dropdown
- Enter a value for the attribute in the right-hand input box.
- Click Save.
Export Your Stitch Application¶
To flush the CDN cache with stitch-cli you need to export an application directory for your application.
You can export your application from the Export tab of the Settings page in the Stitch UI, or by running the following command from an authenticated instance of stitch-cli:
Import the Application Directory¶
To purge the CDN cache, simply include the --reset-cdn-cache
flag
when you import the application directory: