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
|
|
|
|
from zerver.lib.response import json_success
|
|
|
|
from zerver.models import clear_client_cache, flush_per_request_caches
|
|
|
|
|
|
|
|
ZULIP_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../../")
|
|
|
|
|
|
|
|
# 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
|
2021-03-24 12:18:30 +01:00
|
|
|
def remove_caches(request: HttpRequest) -> HttpResponse:
|
|
|
|
cache = get_cache_backend(None)
|
|
|
|
cache.clear()
|
|
|
|
clear_client_cache()
|
|
|
|
flush_per_request_caches()
|
|
|
|
return json_success()
|