Hi @Duy Nguyen
1.Why is AFD with cache enabled very slow when handling POST requests?
Only requests that use the GET request method are cacheable. All other request methods are always proxied through the network. This means POST requests are never cached by AFD. Therefore, the perceived slowness is not due to cache lookups, but rather the fact that AFD is forwarding the entire POST request to your origin server every time.
Since AFD is always sending POST requests to the origin, the origin server becomes the bottleneck.
2. Does the cache-checking step of AFD always happen for all request methods?
While the documentation emphasizes that only GET requests are cacheable, this does not mean AFD entirely skips cache-related processing for other request methods.
AFD's architecture likely involves a stage where it evaluates requests against its routing and caching rules. This evaluation happens regardless of the request method.
The cache checking step is more of a rule's evaluation step. The front door needs to evaluate if there is any rule that applies to the request, and those rules could be related to caching, even if the request is not cacheable.
3. If question 2 is a yes, why is that true for POST requests? In the documentation about caching of AFD, it says that only GET requests are cacheable. If POST requests cannot be cached, why does AFD still check data in the cache for them?
AFD's Rules Engine allows you to define complex rules that can apply to any request, regardless of the method. These rules might include:
URL rewrites, Header modifications, Routing decisions, WAF rules
Even for POST requests, AFD needs to evaluate these rules. The cache-related checks are part of this broader rule evaluation process and for efficiency and consistency, AFD likely uses a unified request processing pipeline. This pipeline might include a stage where all requests are checked against the cache rules, even if the request method is not cacheable.
Kindly let us know if the above helps or you need further assistance on this issue.