Anti-DDoS Proxy provides scrubbing centers that are integrated with web page caching techniques to protect your website services against DDoS attacks and accelerate access to static web pages. This topic describes how to configure the website acceleration feature.
Introduction to the website acceleration feature
Only Anti-DDoS Proxy instances that use the Enhanced function plan support the website acceleration feature. After you enable the website acceleration feature, an Anti-DDoS Proxy instance automatically detects whether the web pages that a client requests contain the resource types that are defined in the caching rule. If the web pages contain the resource types that are defined in the caching rule, the web pages are cached to the protection clusters of Anti-DDoS Proxy. The next time the client requests the same pages, Anti-DDoS Proxy directly returns the pages.
You can customize caching rules for a specific page.
Static resources are cached for 5 minutes on a single host in the protection clusters of Anti-DDoS Proxy. If the interval between two requests for a static resource on a host is more than five minutes, the resource is considered inactive. In this case, the static resource is deleted. When a client requests the static resource again, Anti-DDoS Proxy requests the resource from the origin server.
If the response of the origin server contains the
X-Cache
HTTP header, Anti-DDoS Proxy passes through this header to the client.If the response of the origin server does not contain the
X-Cache
HTTP header, Anti-DDoS Proxy returnsX-Cache: MISS
to the client.
In scenarios with low queries per second (QPS), Anti-DDoS Proxy may return X-Cache: MISS
to a number of clients. This is because the website acceleration feature of Anti-DDoS Proxy is designed for scenarios in which volumetric attacks are launched, which is different from the website acceleration feature of Alibaba Cloud CDN.
Prerequisites
Your website is added to an Anti-DDoS Proxy instance that uses the Enhanced function plan. For more information, see Add one or more websites.
Procedure
Log on to the Anti-DDoS Proxy console.
In the top navigation bar, select the region of your instance.
Anti-DDoS Proxy (Chinese Mainland): If your instance is an Anti-DDoS Proxy (Chinese Mainland) instance, select Chinese Mainland.
Anti-DDoS Proxy (Outside Chinese Mainland): If your instance is an Anti-DDoS Proxy (Outside Chinese Mainland) instance, select Outside Chinese Mainland.
In the left-side navigation pane, choose
.In the upper part of the Website Acceleration page, select the domain name that you want to manage. In the Static Page Caching section, turn on Status and configure the Mode parameter.
ImportantYou can enable static page caching only for the domain names that are associated with an Anti-DDoS Proxy instance that uses the Enhanced function plan.
Standard: If the requested page contains static resources such as CSS, JavaScript, or TXT files, the page is cached.
Enhanced: All requested pages are cached.
No Caching: No requested pages are cached.
After you enable static page caching for the domain name, the caching policy takes effect on all URIs in the domain name. If you want to enable static page caching for only a specific URI, we recommend that you set the Mode parameter to No Caching and perform the following steps to configure a custom caching rule.
Optional. Configure a custom caching rule for a specific URI.
ImportantThe custom caching rule takes effect only after you turn on Status. The custom caching rule preferentially takes effect over the caching policy of the domain name.
You can create a maximum of five custom caching rules.
In the Static Page Caching section, click Settings.
On the page that appears, click Create Rule in the upper-right corner. In the Create Rule dialog box, configure the parameters and click OK. The following table describes the parameters.
Parameter
Description
Rule Name
The name of the rule.
The name can contain letters, digits, and underscores (_). The name can be up to 128 characters in length.
URI
The URI of the page to be cached.
Request parameters and wildcards are not supported for the URI parameter.
For example,
/a/
represents all pages in the path<Domain name>/a/
.Mode
The caching mode. Valid values:
Standard Mode: If the requested page contains static resources such as CSS, JavaScript, or TXT files, the page is cached.
Strong Mode: All requested pages are cached.
No Caching: No requested pages are cached.
Cache Expires In
The validity period of cached static resources. Default value: Use Origin Configurations. This value indicates that the validity period of the cached static resources configured for the origin server is used. You can also select 1Hours, 1Days, 10Days, or 30Days.
For example, if you set the value to 30Days, the Anti-DDoS Proxy instance reobtains the static resources after 30 days.
NoteIf the interval between two requests for a static resource on a single host in the protection clusters of Anti-DDoS Proxy is more than five minutes, the static resource is considered inactive. In this case, the static resource is deleted regardless of the Cache Expires In parameter.
You can find the created rule in the rule list and click Edit or Delete in the Actions column to manage the rule. You can also click Refresh Cache to manually refresh the cache of the page.