Customize cache configuration
After you set up and test the Fastly service in your Staging and Production environments, review and customize cache configuration settings. For example, you can update settings to enable force TLS to redirect HTTP requests to Fastly, update purge settings, and enable basic authentication to password-protect your site during development.
The following sections provide an overview and instructions for configuring some cache settings. Find additional information about the available configuration options in the documentation.
Force TLS
Fastly provides the Force TLS option for redirecting unencrypted requests (HTTP) to Fastly. After your Staging or Production environment has been provisioned with a valid SSL/TLS certificate, you can update the Fastly configuration for your store to enable the Force TLS option. See the Fastly in the Fastly CDN Module for Magento 2 documentation.
Extend Fastly timeout
The Fastly service configuration specifies a default timeout period of 180 seconds for HTTPS requests to the Admin. Any request processing that exceeds the timeout period returns a 503 error. As a result, you can receive 503 errors in response to requests that require lengthy processing, or when trying to perform bulk operations.
To complete bulk actions that take longer than 3 minutes change the Admin path timeout value_ to prevent 503 errors.
To extend the Fastly timeout for the Admin:
-
Log in to the Admin.
-
Click Stores > Settings > Configuration > Advanced > System and expand Full Page Cache.
-
In the Fastly Configuration section, expand Advanced Configuration.
-
Set the Admin path timeout value in seconds. This value cannot be more than 10 minutes (600 seconds).
-
Click Save Config at the top of the page.
-
After the page reloads, select Upload VCL to Fastly in the Fastly Configuration section.
Fastly retrieves the Admin path for generating the VCL file from the app/etc/env.php
configuration file.
Configure purge options
Fastly provides multiple types of purge options on your Magento Cache Management page, including options to purge product category, product assets, and content. When enabled, Fastly watches for events to automatically purge those caches. If you disable a purge option, you can manually purge Fastly caches after finishing updates through the Cache Management page.
The purge options include:
- Purge category–Purges product category content (not product content) when you add and update a single product. You may want to keep this disabled and enable purge product, which purges products and product categories.
- Purge product–Purges all product and product category content when saving a single modification to a product. Enabling purge product can be helpful to immediately get updates to customers when changing a price, adding a product option, and when product inventory is out-of-stock.
- Purge CMS page–Purges page content when updating and adding pages to the ÃÛ¶¹ÊÓƵ Commerce CMS. For example, you may want to purge when updating your Terms and Conditions or Return policy. If you rarely make these changes, you could disable automatic purging.
- Soft purge–Sets changed content to stale and purges according to the stale timing. In addition to the stale timings, customers are served stale content while Fastly updates the content in the background.
To configure Fastly purge options:
-
In the Fastly Configuration section, expand Advanced Configuration to display the purge options.
-
For each purge option, select Yes to enable automatic purging, or No to disable automatic purging.
When you disable a purge option, you must manually purge the cache for that category from the Cache Management page.
-
Click Save Config at the top of the page.
-
After the page reloads, select Upload VCL to Fastly in the Fastly Configuration section.
For more information, see .
Configure GeoIP handling
The Fastly module includes GeoIP handling to automatically redirect visitors or provide a list of stores matching their obtained country code. If you already use an extension for GeoIP handling, you may need to verify the features with Fastly options.
To set up GeoIp handling:
-
Log in to the Admin.
-
Click Stores > Settings > Configuration > Advanced > System and expand Full Page Cache.
-
In the Fastly Configuration section, expand Advanced Configuration.
-
Scroll down and select Yes to Enable GeoIP. Additional configuration options display.
-
For GeoIP Action, select if the visitor is automatically redirected with Redirect or provided a list of stores to select from with Dialog.
-
For Country Mapping, select Add to enter a two-letter country code to map with a specific ÃÛ¶¹ÊÓƵ Commerce store from a list.
-
Click Save Config at the top of the page.
-
After page reload, select Upload VCL to Fastly in the Fastly Configuration section.
Fastly also provides a series of for customized geolocation coding.
Enable Fastly Edge modules
Fastly Edge Modules is a flexible framework that allows definition of UI components and associated VCL code through a template. These modules make it easy to customize and extend the Fastly service configuration through the user interface instead of using custom VCL snippets.
Edge modules allow you to enable specific functionality like CORS headers, Cloud Sitemap rewrites, and to configure integration between your ÃÛ¶¹ÊÓƵ Commerce store and other CMSs or back ends.
To access the Edge Modules menu to view, configure, and manage the available modules, turn on the Enable Fastly Edge modules option. See in the Fastly CDN module documentation.
Configure back ends and Origin shielding
Back-end settings provide fine tuning for Fastly performance with Origin shielding and timeouts. A back end is a specific location (IP or domain) with configured Origin shield and timeout settings for checking and providing cached content.
Origin shielding routes all requests for your store to a specific Point of Presence (POP). When a request is received, the POP checks for cached content and provides it. If it is not cached, it continues to the Shield POP, then to the Origin server which caches the content. The shields reduce traffic directly to the origin.
The default Fastly VCL code specifies default values for Origin shielding and timeouts for your ÃÛ¶¹ÊÓƵ Commerce on cloud infrastructure sites. In some case, you might need to modify the default values. For example, if you are getting Time to First Byte (TTFB) errors, you might need to adjust the first byte timeout value.
To review the backend settings configuration:
-
Log in to the Admin.
-
Click Stores > Settings > Configuration > Advanced > System and expand Full Page Cache.
-
Expand the Fastly Configuration section.
-
Expand Backend settings and select the gear to check the default back end. A modal opens that shows current settings with options to change them.
-
Select the Shield location (or data center).
The default Fastly configuration for your project sets the location closest to your Cloud service region. If you need to change it, select a location close to the default location.
-
Modify the timeout values (in microseconds) for the connection to the shield, time between bytes, and time for the first byte. We recommend keeping the default timeout settings.
-
Optionally, select to Activate the backend and Shield after editing or saving.
-
Click Upload to save your changes and upload them to the Fastly servers.
-
In the Admin, select Save Config.
For more information, see the in the Fastly module documentation.
Basic authentication
Basic authentication is a feature to protect every page and asset on your site
with a username and password. We do not recommend activating basic
authentication on your Production environment. You can configure it on Staging
to protect your site during the development process. See the in the Fastly CDN module documentation.
If you add user access and enable basic authentication on Staging, you can still
access the Admin without requiring additional credentials.
Create custom VCL snippets
Fastly supports a customized version of the Varnish Configuration Language (VCL) to customize the Fastly service configuration. For example, you can allow, block, or redirect access for specific users or IP addresses using VCL code blocks with edge and Access Control List (ACL) dictionaries.
For instructions to create custom VCL snippets, edge dictionaries, and ACLs, see Custom Fastly VCL snippets.
Manage domains
For both Starter and Pro projects, you can use the Domains option to add and manage the Fastly domain configuration for your store.
-
For Starter projects, go to Project URL under the Domains tab in the Cloud Console to add your Project URL.
-
For Pro projects, submit an ÃÛ¶¹ÊÓƵ Commerce Support ticket to add the domain to your cloud project configuration. The Support team also updates the ÃÛ¶¹ÊÓƵ Commerce Fastly account configuration to add the domain.
To manage Fastly domain configuration from the Admin:
-
Log in to the Admin.
-
Select Stores > Settings > Configuration > Advanced > System and expand Full Page Cache.
-
In the Admin Fastly Configuration section, select Domains.
-
Click Manage Domains to open the Domains page.
-
Add the top-level and subdomain names for the stores in the Cloud environment.
You can only specify domains that have already been added to your Cloud infrastructure configuration.
-
Click Activate to update the Fastly domain configuration.
Enable Maintenance Mode
Use the Maintenance Mode option to allow administrative access to your site from specified IP addresses while returning an error page for all other requests.
To enable Maintenance mode with Administrative access:
-
Open the Fastly configuration section in the Admin.
-
In the Edge ACL section, update the
maint_allow
access control list (ACL) with the administrative IP addresses that can access your store while it is in Maintenance mode. -
In the Maintenance Mode section, select Enable Maintenance Mode.
After you enable maintenance mode, all traffic is blocked except requests from the IP addresses in the
maint_allowlist
ACL. You can update themaint_allowlist
to change the IP addresses in the ACL.For detailed configuration instructions, see the in the Fastly CDN for Magento 2 module documentation.