WEBER.cloud China proxy cache server: deleting the cache
Posted by , Last modified by Marc Füßlein on 04 January 2022 10:08
The cache is built up reactively. As soon as a website visitor needs a file for the first time, the proxy cache server sends a request to your web server. The file is then placed in the cache. Subsequent requests of the same file can then be answered directly from the cache for the cache duration, thus significantly improving the performance of your website in China.
A proactive build-up or a warm-up of the cache can be achieved by flushing the cache and then running a crawler over the website. At the moment this still requires its own crawler logic, in the future there will be the possibility of initiating website crawling on the proxy cache server.
By default, the proxy cache server provides the following durations for caching files:
The precise cache logic for your website is determined when setting up the proxy cache server. Cache durations can be adjusted, additional cache durations can be created for certain file types or certain areas, and pages can be completely excluded from caching. For each file, you can also specify the desired cache duration in seconds via the HTTP header information "X-Accel-Expires". This value overwrites the generally defined cache durations and allows you to specify cache durations for specific files as needed.
Manually deleting files from the cache
Due to the caching of files, changes to your website will only be visible in China after a certain delay. The proxy cache server therefore provides several options for manually renewing individual files in the cache or for rebuilding the entire cache.
The associated cache controlling can be reached via the path /cache/purge and can therefore also be operated directly in the browser. The structure of the URLs is as follows:
When using the cache controlling you have to authenticate yourself with the corresponding access data, which you will receive from us during the setup of the proxy cache server. If you no longer have the access data to hand, please do not hesitate to contact us.
Please always note: Deleting files from the cache results in temporary performance losses for your website in China, as the cache has to be rebuilt first. For this reason we strongly recommend: Delete as many files as necessary, but as few as possible. The entire cache should only be cleared in exceptional situations, as this has the greatest negative impact on the performance of your website in China. If you find that you keep renewing the same pages or areas in the cache, please feel free to contact us so that we can optimize the cache rules accordingly and save you manual work.
1. Renew a single file
Suppose you want to refresh the following file in the cache: http://www.your-selected-name.com/images/image.jpg
In this case you simply have to go to the following URL in your browser: http://www.your-selected-name.com/cache/purge/images/image.jpg
After deleting, you will be redirected to http://www.your-selected-name.com/images/image.jpg, which immediately retrieves the latest version of the file and stores it in the cache.
2. Delete multiple files from the cache
You can use wildcard notation when deleting multiple files.
Variant 1: Delete all files with a certain ending in a subfolder
Suppose you want to delete all JPG images in the subdirectory /images/ from the cache. In this case, go to the following URL: http://www.your-selected-name.com/cache/purge/images/*.jpg
With this call, for example, the following files are deleted from the cache:
Files with a different extension or in a subfolder are not deleted. This means that the following files would continue to be obtained from the cache unchanged:
Variant 2: Recursive deletion of all files in a folder and all sub-folders
Suppose you want to delete all files in the subdirectory /images/ from the cache. Then simply call up the following URL: http://www.your-selected-name.com/cache/purge/images/*
Compared to the first variant of deletion via wildcard, the URL ends with an asterisk. This means that the deletion is recursive and includes subfolders. For example, the following files are deleted from the cache:
Please note that when deleting multiple files, exactly one wildcard notation may be present in the URL. It is not possible to use multiple wildcards in the URL.
With both variants you will be redirected to the start page after deletion.
3. Flush the entire cache
The deletion of the entire cache is in principle a modification of the recursive deletion by wildcard, in which no sub-path is specified: http://www.your-selected-name.com/cache/purge/*
After deleting you will be redirected to the start page.
4. Deletion via API
The aim of the cache controlling described above is that files can be deleted from the cache comfortably and directly by calling up a suitable URL in the browser. Of course, this process can be automated. The use of curl requests is particularly suitable for this.
Renew a single file:
curl -u user:password http://www.your-selected-name.com/cache/purge/images/image.jpg
Delete multiple files from the cache:
curl -u user:password http://www.your-selected-name.com/cache/purge/images/*
Flush the entire cache:
curl -u user:password http://www.your-selected-name.com/cache/purge/*
The use of PURGE instead of GET requests for deletion from the cache is currently not explicitly supported by the proxy cache server. PURGE requests are implicitly interpreted as GET requests. If you prefer to use a PURGE request, you still have to make sure that you are calling the correct URL, including the path /cache/purge.
Old method of deleting via URL parameters
Deletion is currently still possible via URL parameters and we have configured a corresponding mapping to the new cache controlling on the proxy cache servers.
Delete a single file
Clear the entire cache
Although it is currently still possible to delete using URL parameters, we strongly recommend that you upgrade to the new version of cache controlling. On the one hand, you have extensive access to the wildcard notation