CDN Headers Sent to the User and the Origin Server
When a website uses the Arvancloud CDN, its visitors' requests reach Arvancloud CDN servers instead of the origin server hosting the site. In response to these requests, the CDN edge server sends several headers to the visitor, which show the status of the sent request and the server's response.
Also, when a request is sent from the CDN edge server to the origin server hosting the website, headers are added to that request. These headers can also be customized, which is available to users on the Enterprise plan.
Each of these headers is described below.
Headers Sent to the User
X-Request-Id
This header assigns a unique code to each request sent from the visitor to the CDN edge server, so that, if needed, you can search for it and find out the status of the request on the CDN.
Also, if the user uses Arvancloud log forwarding, they can search for this header's value in their log server's logs to get detailed information about the status of the request.
X-Sid
A four-digit code that shows the unique number of the CDN edge server the visitor is connected to.
Server-Timing
This header shows how long it took the CDN server to get the related content. The content can come from the CDN's cache or from the origin server hosting the site. The value of this header is in milliseconds.
X-Cache
When your website's resources are cached on Arvancloud edge servers, Arvancloud adds a special header named X-Cache so you can see the cache status of these resources.
In this header, the cache status can be one of the following:
-
HIT
This status in
X-Cachemeans the requested resource is cached on the Arvancloud edge server and the response is served by these servers. -
MISS
This status means the requested resource does not exist on the Arvancloud edge server and the response is served by the origin server hosting the site.
-
EXPIRED
This status means the requested resource exists on the Arvancloud edge server, but because it has expired in this server's cache, the request was answered by the origin server hosting the site.
-
STALE
This status means the Arvancloud edge server sent an old, expired resource in the response, because it is at the same time revalidating this resource from the origin server hosting the site due to another user's request. This status rarely happens.
-
BYPASS
This status means the requested resource cannot be cached.
-
REVALIDATED
This status means the Arvancloud edge server used the old version of the requested resource that was in its cache to respond. The difference is that in this case, the edge server has revalidated this resource with the origin server hosting the site using the
If-Modified-SinceorIf-None-Matchheader. -
UPDATING
This status means the requested resource is being updated on the Arvancloud edge server, and the response just sent was the old version in this server's cache. This status usually happens when a large resource (in size) is being cached on the edge server.
X-Xss-Protection
An XSS attack is a type of web vulnerability found in many websites. Unfortunately, web developers ignore this bug or don't know enough about preventing it, even though this security flaw is very dangerous. Using various methods, the attacker injects their own JavaScript or HTML code into the user or users of a page that has an XSS bug. This code then runs in the user's browser and exposes the user to various, very dangerous risks. Modern browsers have several features against XSS attacks, which are usually enabled by default. To use these browser features, simply use the X-Xss-Protection header in the response to a browser's request.
Content-Security-Policy
When a website uses HTTPS but its HTML pages still contain links with the HTTP protocol, the browser shows an error called Mixed Content to maintain security, meaning there may be a security problem with the HTTP links.
In the Arvancloud panel, under HTTPS Settings, there is an option you can use to fix this problem.
When you enable this feature, the Content-Security-Policy header is added to the headers sent to the user, and the browser is told to change the link from HTTP to HTTPS if it runs into this problem.
Strict-Transport-Security
When you enable HSTS in the Arvancloud CDN panel, this header is added to the headers sent to the user, telling the browser that for a specific period (such as one month), if the first request to the website is HTTP, the browser should automatically convert it to an HTTPS request.
Headers Sent to the Origin Server
X-Sid
A four-digit code that is the unique number of the CDN server the request was sent from.
X-Real-IP
This is a standard HTTP header. When a website uses a CDN and a visitor sends a request to the website, the request first reaches the CDN edge servers and is then sent to the website's origin server. So, the IP of the CDN server, instead of the user's real IP, is shown as the sender of the request.
Since many analysis and security processes need the user's real IP, the CDN server uses this HTTP header to send the user's real IP to the origin server.
X-Forwarded-Proto
This is a de facto standard header that specifies the protocol the request first used to reach the CDN servers. For example, if a request was sent from the user to the CDN over HTTP and from the CDN to the origin server over HTTPS, this header shows the value HTTP.
The protocol between visitors and CDN servers, as well as between CDN servers and the origin servers hosting the website, can be set separately in the Arvancloud CDN panel.
X-Forwarded-For
This header is similar to X-Real-IP, except that it also contains the IPs of the proxy servers the user's request passed through to reach the origin server hosting the site, alongside the user's original IP. In fact, this header is an array of IPs that shows the order in which the request passed through multiple servers until it reached the origin server hosting the site.
X-Country-Code
This header contains a two-letter code that shows the country the request was sent from. This information is obtained using the user's IP and extracting its country from up-to-date GeoIP databases.
X-Request-Id
This header assigns a unique code to each request sent to the CDN server, so that, when needed, you can search for and trace it to find out the status of the request on the CDN.
Also, if the user uses Arvancloud log forwarding, they can search for this header's value in their log server's logs to get detailed information about the status of the request.
CDN-Loop
This header helps Arvancloud detect how many times a request can enter the Arvancloud network before it is blocked as a loop. For example:
CDN-Loop: arvancloud; count=1
Accept-Encoding
By default, this header is set to gzip for received requests. If one of the image resize or acceleration modules, or a CDN app from the marketplace, is enabled, Arvancloud sets this header's value as follows:
Accept-Encoding: identify