All Products
Search
Document Center

:Why is the content retrieved from POPs different from the content returned from the origin server?

Last Updated:Oct 14, 2024

If the content retrieved from POPs is different from the content returned from the origin server, the point of presence (POP) may have appended specific headers to an HTTP request redirected from the POP to the origin server. The origin server uses different processing logic for the headers. Therefore, different content is returned.

Problem description

After you use Alibaba Cloud CDN or Dynamic Content Delivery Network (DCDN) to accelerate content delivery, the content returned from POPs is different from the content returned from the origin server.

Causes

When a client request reaches a POP, the following logic is performed:

  • If the request hits the cache: The POP returns the requested content to the client.

  • If the request does not hit the cache: The POP redirects the request to the origin server and appends specific headers to the HTTP request. The following figure shows how a POP redirects a request to the origin server.

    image

In specific scenarios, the origin server may process requests that contain specific headers by using different methods. As a result, the content that is returned from POPs is different from the content that is returned from the origin server. For example, the origin server checks whether an HTTP request contains the Via header to determine whether the request is from a proxy server, and then makes a corresponding response.

Solutions:

  1. Identify the header that causes the issue:

    • Obtain the content from the origin server and record the result.

    • Append specific headers to HTTP request headers by simulating a POP, obtain the content from the origin server, and then record the result.

    • Use different headers to repeat the operation until you identify the header that causes the issue.

  2. Modify origin server configurations or remove the header that causes the issue:

    • Check origin server configurations and modify the response logic for specific headers based on your business requirements.

    • If the header has no practical effect on your service and you are using Alibaba Cloud CDN, you can remove the header in the Alibaba Cloud CDN console. You cannot remove a header in the Secure CDN (SCDN) or DCDN console. To remove a header, submit a ticket to contact Alibaba Cloud technical support.

Solutions

Step 1: Locate the header that causes this issue

Origin servers return different content only for specific headers. Therefore, you need to locate the specific header. To identify the header, perform the following operations:

  1. Obtain the content from the origin server and record the result.

    curl -voa 'http://[$Your_Wesbite]' -x [$Origin_Server_IP]:[$Origin_Server_Port]
    Note
    • [$Your_Wesbite]: the domain name of your website.

    • [$Origin_Server_IP]: the public IP address of the origin server.

    • [$Origin_Server_Port]: the port of the origin server that hosts the website. In most cases, port 80 or 443 is used.

  2. Append specific headers to HTTP request headers by simulating a POP, obtain the content from the origin server, and then record the result.

    curl -voa 'http://www.[$Your_Wesbite].com' -x [$Origin_Server_IP]:[$Origin_Server_Port] -H 'Via:example.aliyundoc.com'
    Note

    In this example, the Via:example.aliyundoc.com header is used. You can use a custom header and value based on your business requirements. For more information about the headers that are appended by Alibaba Cloud CDN, see References.

  3. Compare the results of Step 1 and Step 2.

    • If the results are consistent: Repeat Step 1 and Step 2 and replace the header in Step 2 until inconsistent results are returned.

    • If the results are inconsistent: Record the headers and proceed to the next step.

Step 2: Modify origin server configurations or remove the header that causes the issue

After you locate a specific header, you can use one of the following methods to resolve the issue:

  • Modify origin server configurations. Check whether a configuration that returns different content based on HTTP request headers exists on the origin server. If the configuration exists, modify the configuration based on your business requirements.

  • Remove the header that causes the issue in the Alibaba Cloud CDN console. If the header that causes the issue has no practical effect on your service, you can remove the header in the Alibaba Cloud CDN console. For information about how to remove a request header, see Parameters of the Delete operation.

References

The following section describes the headers that are appended by POPs.

Via: cn2XXX6.l1, vcache10.cnXXX36, l2cnXXX5.l2, cache28.lXXX35
Eagleeye-Traceid: 24689aa4XXXX58162753e
Ali-Swift-Log-Host: example.aliyundoc.com
Ali-Swift-Stat-Host: demo.example.aliyundoc.com
X-Forwarded-For: 58.XX.XX.41
X-Client-Scheme: http
Ali-Cdn-Real-Ip: 58.XX.XX.41
Ali-Swift-5Xx-No-Retry: on
Cdn-Src-Ip: 127.0.0.1
Ali-Swift-Range-Cache: on
Note

The following section describes the headers:

  • Via: information about POPs that the request passes through.

  • Ali-Cdn-Real-Ip: the IP address of the client that sends the request.

  • Ali-Swift-Range-Cache: If you enabled the range origin fetch feature, POPs append this header. For more information, see Range origin fetch.

  • X-Forwarded-For: the standard HTTP XFF field.