Add admin UI button to clear instance cache

Adds a 'Clear Instance Cache' card to /i/admin/settings/system that POSTs to a CSRF-protected route and calls LandingCacheService::invalidate(), which clears every key behind the landing page, /api/v(1|2)/instance, and nodeinfo.

Useful as an escape hatch after manual ConfigCache edits or when debugging stale-cache symptoms (like trying to set up a brand-new instance); under normal operation the event-driven invalidation in surrounding commits makes this unnecessary.
pull/6656/head
Shannon Quinn 2 days ago
parent 793d2c3ef3
commit 7b939e9d65

@ -316,6 +316,13 @@ trait AdminSettingsController
return view('admin.settings.system', compact('sys'));
}
public function settingsClearInstanceCache(Request $request)
{
LandingCacheService::invalidate();
return redirect()->route('admin.settings.system')->with('status', 'Instance cache cleared.');
}
public function settingsApiFetch(Request $request)
{
$cloud_storage = ConfigCacheService::get('pixelfed.cloud_storage');

@ -77,6 +77,22 @@
</div>
</div>
</div>
<hr>
<p class="h6 text-uppercase text-center">INSTANCE CACHE</p>
@if(session('status'))
<div class="alert alert-success">{{ session('status') }}</div>
@endif
<div class="card shadow-none border">
<div class="card-body">
<p class="mb-2">
Clears the cached payloads behind the landing page, <code>/api/v1/instance</code>, <code>/api/v2/instance</code>, and nodeinfo (admin profile, rules, banner blurhash, user and post counts). Safe to run at any time; the values will repopulate on the next request.
</p>
<form method="POST" action="{{ route('admin.settings.system.clear-instance-cache') }}" class="mb-0">
@csrf
<button type="submit" class="btn btn-outline-danger font-weight-bold">Clear Instance Cache</button>
</form>
</div>
</div>
@endsection
@push('styles')

@ -64,6 +64,7 @@ Route::domain(config('pixelfed.domain.admin'))->prefix('i/admin')->group(functio
Route::get('settings/backups', 'AdminController@settingsBackups')->name('admin.settings.backups');
Route::get('settings/storage', 'AdminController@settingsStorage')->name('admin.settings.storage');
Route::get('settings/system', 'AdminController@settingsSystem')->name('admin.settings.system');
Route::post('settings/system/clear-instance-cache', 'AdminController@settingsClearInstanceCache')->name('admin.settings.system.clear-instance-cache');
Route::get('instances', 'AdminController@instances')->name('admin.instances');
Route::post('instances', 'AdminController@instanceScan');

Loading…
Cancel
Save