edit-icon download-icon

How does Alibaba Cloud CDN handle 302 redirection of an origin site?

Last Updated: May 16, 2017

A common requirement of website design is to provide a proper front-end website style based on the client terminal type. A design principle is to allow the origin site to execute 302 redirection based on the user’s request to redirect the user to a page where the user will obtain the desired services.

After Alibaba Cloud CDN is deployed for a website, Alibaba Cloud CDN will cache the resources accessed by users to Alibaba Cloud CDN nodes to accelerate subsequent access. In this case, the 302 request sent after access by the first user may be cached. When other users with different types of terminal devices access the website by using the same URL, the website may still display the page mapped to the 302 request cached for the first user. This will make the terminal-type-based page adaptation feature of the origin site ineffective.

To solve the problem, configure caching of the page displayed after 302 redirection, and set the initially requested URL to no-cache. This configuration ensures that the terminal-type-based page adaptation feature of the origin site takes effect and page delivery through Alibaba Cloud CDN is accelerated. Alibaba Cloud CDN supports two methods of cache configuration: directory-based cache configuration and suffix-based cache configuration. You can define the caching of other URLs than the initial URL based on the directory structure of your site by combining the two configuration methods and their respective priorities. A more convenient method is to set the initial page file to no-cache at the origin site, because the no-cache policy of the origin site has a higher priority for Alibaba Cloud CDN. The initial page is not cached when it contains the following response headers:

  • Cache-control:no-cache,no-store,private

  • Cache-control:s-maxage=0,max-age=0

  • pragma:no-cache

If the problem persists, contact Alibaba Cloud After-Sales Technical Support.

Thank you! We've received your feedback.