Bearsampp 2026.9.23
Loading...
Searching...
No Matches
ajax.clearcache.php
Go to the documentation of this file.
1<?php
2/*
3 * Copyright (c) 2026 Bearsampp
4 * License: GNU General Public License version 3 or later; see LICENSE.txt
5 * Website: https://bearsampp.com
6 * Github: https://github.com/Bearsampp
7 */
8
16header('Content-Type: application/json');
17header('Cache-Control: no-store');
18
20
21try {
23 Log::error('Cache clear attempted while caching is disabled');
24 $response = [
25 'success' => false,
26 'error' => 'Caching is disabled.',
27 ];
28 echo json_encode($response);
29 exit;
30 }
31
32 $deleted = CacheManager::clearAll();
34
35 $response = [
36 'success' => true,
37 'deleted' => $deleted,
38 'filesCount' => $stats['filesCount'],
39 'totalSize' => $stats['totalSize'],
40 'oldestEntry' => $stats['oldestEntry'],
41 'newestEntry' => $stats['newestEntry'],
42 'largestEntry' => $stats['largestEntry'],
43 ];
44
45 Log::info('Cache cleared from homepage: ' . $deleted . ' files deleted');
46} catch (Exception $e) {
47 Log::error('Error clearing cache: ' . $e->getMessage());
48 $response = [
49 'success' => false,
50 'error' => $e->getMessage(),
51 ];
52}
53
54echo json_encode($response);
static info($data, $file=null)
static error($data, $file=null)
static getCacheStats()