How to clear all caches in Apache?
I have a django app running in a virtualenv on Windows 10 WSL1 (Ubuntu). The python version is 3.6.8. When using the django development web server, python manage.py runserver , everything is fine. I access that with http://localhost:8000/
a2dismod cache Module cache already disabled.
Also ran htcacheclean -r -l1k and manually looked at the page cache directory, which was empty. I clear the Chrome cache on every page load, but also get the same errors when using a different browser (Firefox) that wasn’t even installed when this old code that’s showing up was written. I put in a HTTP header to request no caching: The closest thing to a cache that I have configured in Django settings is SESSION_ENGINE = ‘django.contrib.sessions.backends.cached_db’ , no CACHES settings. And, of course, I stopped and restarted Apache.
service apache2 stop service apache2 start
htcacheclean — Clean up the disk cache
htcacheclean is used to keep the size of mod_cache_disk ‘s storage within a given size limit, or limit on inodes in use. This tool can run either manually or in daemon mode. When running in daemon mode, it sleeps in the background and checks the cache directory at regular intervals for cached content to be removed. You can stop the daemon cleanly by sending it a TERM or INT signal. When run manually, a once off check of the cache directory is made for cached content to be removed. If one or more URLs are specified, each URL will be deleted from the cache, if present.
- Synopsis
- Options
- Deleting a specific URL
- Listing URLs in the Cache
- Exit Status
See also
Synopsis
htcacheclean [ —D ] [ —v ] [ —t ] [ —r ] [ —n ] [ —R round ] —p path [ —l limit ] [ —L limit ]
htcacheclean [ —n ] [ —t ] [ —i ] [ —P pidfile ] [ —R round ] —d interval —p path [ —l limit ] [ —L limit ]
htcacheclean [ —v ] [ —R round ] —p path [ —a ] [ —A ]
htcacheclean [ —D ] [ —v ] [ —t ] [ —R round ] —p path url
Options
-d interval Daemonize and repeat cache cleaning every interval minutes. This option is mutually exclusive with the -D , -v and -r options. To shutdown the daemon cleanly, just send it a SIGTERM or SIGINT . -D Do a dry run and don’t delete anything. This option is mutually exclusive with the -d option. When doing a dry run and deleting directories with -t , the inodes reported deleted in the stats cannot take into account the directories deleted, and will be marked as an estimate. -v Be verbose and print statistics. This option is mutually exclusive with the -d option. -r Clean thoroughly. This assumes that the Apache web server is not running (otherwise you may get garbage in the cache). This option is mutually exclusive with the -d option and implies the -t option. -n Be nice. This causes slower processing in favour of other processes. htcacheclean will sleep from time to time so that (a) the disk IO will be delayed and (b) the kernel can schedule other processes in the meantime. -t Delete all empty directories. By default only cache files are removed, however with some configurations the large number of directories created may require attention. If your configuration requires a very large number of directories, to the point that inode or file allocation table exhaustion may become an issue, use of this option is advised. -p path Specify path as the root directory of the disk cache. This should be the same value as specified with the CacheRoot directive. -P pidfile Specify pidfile as the name of the file to write the process ID to when daemonized. -R round Specify round as the amount to round sizes up to, to compensate for disk block sizes. Set to the block size of the cache partition. -l limit Specify limit as the total disk cache size limit. The value is expressed in bytes by default (or attaching B to the number). Attach K for Kbytes, M for MBytes or G for Gbytes. -L limit Specify limit as the total disk cache inode limit. K , M or G suffix can also be used. -i Be intelligent and run only when there was a modification of the disk cache. This option is only possible together with the -d option. -a List the URLs currently stored in the cache. Variants of the same URL will be listed once for each variant. -A List the URLs currently stored in the cache, along with their attributes in the following order: url, header size, body size, status, entity version, date, expiry, request time, response time, body present, head request.
Deleting a specific URL
If htcacheclean is passed one or more URLs, each URL will be deleted from the cache. If multiple variants of an URL exists, all variants would be deleted.
When a reverse proxied URL is to be deleted, the effective URL is constructed from the Host header, the port, the path and the query. Note the ‘?’ in the URL must always be specified explicitly, whether a query string is present or not. For example, an attempt to delete the path / from the server localhost, the URL to delete would be http://localhost:80/?.
Listing URLs in the Cache
By passing the -a or -A options to htcacheclean , the URLs within the cache will be listed as they are found, one URL per line. The -A option dumps the full cache entry after the URL, with fields in the following order:
url The URL of the entry. header size The size of the header in bytes. body size The size of the body in bytes. status Status of the cached response. entity version The number of times this entry has been revalidated without being deleted. date Date of the response. expiry Expiry date of the response. request time Time of the start of the request. response time Time of the end of the request. body present If 0, no body is stored with this request, 1 otherwise. head request If 1, the entry contains a cached HEAD request with no body, 0 otherwise.
Exit Status
htcacheclean returns a zero status («true») if all operations were successful, 1 otherwise. If an URL is specified, and the URL was cached and successfully removed, 0 is returned, 2 otherwise. If an error occurred during URL removal, 1 is returned.
Comments
Notice:
This is not a Q&A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Libera.chat, or sent to our mailing lists.
Copyright 2023 The Apache Software Foundation.
Licensed under the Apache License, Version 2.0.
Как сбросить кеш Apache (за 4 шага)
Apache — это программное обеспечение веб-сервера с открытым исходным кодом, используемое для размещения и обслуживания простых и сложных веб-сайтов и веб-приложений, запускаемых в веб-браузерах. Как и многие другие типы программного обеспечения, Apache использует серию каталогов для кэширования файлов, созданных и используемых в будущем приложении. Хранение временных файлов кэша упрощает работу с приложением, сокращая время, необходимое программе для запроса данных, необходимых для продолжения работы. По мере накопления кеша Apache может замедляться. Сброс кеша — это способ для администраций Apache ускорить работу веб-сервера и устранить проблемы.
Шаг 1
Запустите терминальное соединение с веб-сервером Apache и убедитесь, что вы вошли в систему как пользователь root, что является максимальным уровнем разрешений для внесения изменений в файловую систему на веб-сервере Apache.
Шаг 2
Введите команду «htcacheclean -D», а затем нажмите клавишу «ОК» на клавиатуре, чтобы запустить тест сброса кеша. Перед выполнением аппаратного сброса рекомендуется запустить тестовый прогон, чтобы избежать ошибочного удаления каталогов кеша, которые используются в качестве зависимостей для других приложений, работающих на веб-сервере Apache.
Шаг 3
Введите команду «htcacheclean -r» и затем нажмите клавишу «OK» на клавиатуре, чтобы выполнить глубокую очистку папок кеша, используемых Apache.
Шаг 4
Перезагрузите веб-сервер Apache, набрав команду «apachectl restart» и нажав «OK».