2021-03-24 12:18:30 +01:00
|
|
|
import os
|
|
|
|
|
|
|
|
from django.http import HttpRequest, HttpResponse
|
2021-03-25 20:47:54 +01:00
|
|
|
from django.views.decorators.csrf import csrf_exempt
|
2021-03-24 12:18:30 +01:00
|
|
|
|
2021-03-25 20:47:54 +01:00
|
|
|
from zerver.decorator import require_post
|
2021-03-24 12:18:30 +01:00
|
|
|
from zerver.lib.cache import get_cache_backend
|
2023-07-14 19:46:50 +02:00
|
|
|
from zerver.lib.per_request_cache import flush_per_request_caches
|
2021-03-24 12:18:30 +01:00
|
|
|
from zerver.lib.response import json_success
|
2023-12-15 04:33:19 +01:00
|
|
|
from zerver.models.clients import clear_client_cache
|
2021-03-24 12:18:30 +01:00
|
|
|
|
|
|
|
ZULIP_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../../")
|
|
|
|
|
2023-02-02 04:35:24 +01:00
|
|
|
|
2021-05-10 07:02:14 +02:00
|
|
|
# This is used only by the Puppeteer tests to clear all the cache after each run.
|
2021-03-25 20:47:54 +01:00
|
|
|
@csrf_exempt
|
|
|
|
@require_post
|
2023-05-30 00:01:44 +02:00
|
|
|
def remove_caches(request: HttpRequest) -> HttpResponse: # nocoverage
|
2021-03-24 12:18:30 +01:00
|
|
|
cache = get_cache_backend(None)
|
|
|
|
cache.clear()
|
|
|
|
clear_client_cache()
|
|
|
|
flush_per_request_caches()
|
2022-01-31 13:44:02 +01:00
|
|
|
return json_success(request)
|