Caching is the temporary saving of web data to increase efficiency and reduce delay. Website data is cached in various layers when the caching feature is activated in the ArvanCloud CDN service to increase accessibility, efficiency, and high availability. When the requested data is not present in CDN, the user’s request is forwarded to the origin server. The response is then saved, and other similar requests are not sent to the origin server again and are answered from the cache. The only exception is in the case of revalidation. Not all web data is cached. Some requests must always be sent to the main server. Usually, static data such as images, JS, and CSS files are cached. Data that is responded to through cache is called Hit, and those sent to the origin server are called Miss. To determine whether a data was a Hit or Miss, check the ar-cache Response Header. To check Response Headers on the Chrome browser, go to the settings and select Developer Tools.
To configure the Caching settings of the ArvanCloud CDN service, you need to go to the Caching Settings of your account. You can configure the cache level, caching expiration time, purge cache, always-online, and the development mode in the opened window. This page will explain these options.
Cache Performance Level
You can activate or deactivate different caching levels in your ArvanCloud user panel.
Turned off: In this state, no data will be cached, and all requests will be forwarded to the origin server.
Ignore Query String: In this case, the query string in the URL will be ignored. All the requests for one URL but with different query strings will receive the same cached response. For example, if the request, https://www.arvancloud.ir/assets/images/pages/cdn/cloudDNS.svg?x=test has already been sent to the CDN and stored in the cache, the request https://www.arvancloud.ir/assets/images/pages/cdn/cloudDNS.svg?x=abcdefg1234 will also be responded to from cache (hit).
Apply Query String: In this case, unlike the previous one, all the query strings will be considered, and the two requests will be sent to one URL but the different query strings will be in two different content caches. Therefore, in the case of the two previous requests, they will be a Miss.
Apply Query String + Cookie: In this case, the value of cookies in the request header will be considered along with the query string.
For example, for a request with one URL, the cookie value is: Cookie: test=123; other=abc We want the test variable in the cookie value to be different from the cached value. You can set the desired cookie variable with test. In this case, when a request is sent to the same URL but with the header: Cookie: test=567; other=abc The result will be a Miss.
If the desired variable is not in the cookie, the cookie will not be considered.
You can also configure the setting to consider a specific query string to cache. Turn off apply all query strings and set your desired variables in Apply a Special Query String.
Cache Expiration Time
In this section, you can set a duration of time for keeping cached files in different levels.
Cache Max Age: The duration of time that the saved data will not be deleted from cache.
Cache Max Age for Other Pages: Caching duration of pages with status codes other than 200 on CDN edge servers.
Browser Cache TTL: The duration of time the browser can keep the cached files.
Cache Pages with Set-Cookie: When this is turned off, the responses from the server that have set-cookie headers will not be cached. The caching will ensue once the option is turned on.
You can delete cached files in the ArvanCloud user panel. Here is how:
Specific URL Purge: If you want to delete certain files from cache, you can click on this option, enter the URL and delete them selectively.
Purge by Tag: When you define tags for your cached data, these tags become cache-tag in the header as the content’s metadata. You can purge the tagged content cache in the ArvanCloud user panel.
Purge All: You can delete all cached files in a domain.
This option allows the ArvanCloud CDN to respond to your users’ requests with the cached data when your website is out of service.
When your website is out of service, it’s not possible to cache new data in the CDN service. You can set suitable rules for your website’s pages on what needs to be cached before this problem occurs.
It is sometimes necessary to disable caching when checking the deployed changes on a website during programming.
This option disables caching temporarily, though the previously cached data remains and is not deleted. Once the option is off, caching continues.
ArvanCloud CDN’s Default Cacheable Extensions
If you have not specified page rules for your website in the CDN section of ArvanCloud panel, a group of file extensions will be used as the default for the ArvanCloud edge servers automatically. There will be no need for further configurations for caching. These extensions are: