Speed legacy photo serving and skip tracking on download routes.

Tighten thumbnail/legacy photo handling and exclude download/photo traffic from session visitor tracking so those hot paths stay cheap.
This commit is contained in:
2026-08-29 12:25:37 +02:00
parent e9cf754b37
commit b9beb8f5c5
8 changed files with 235 additions and 11 deletions
@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
use App\Services\Traffic\OnlineVisitorRepository;
use Illuminate\Support\Facades\Config;
beforeEach(function (): void {
Config::set('skinbase-sessions.enabled', true);
Config::set('skinbase-sessions.debug_header', true);
Config::set('skinbase-sessions.skip_anonymous_public_get', true);
});
it('skips session for anonymous GET and HEAD /photo/* without a session cookie', function (): void {
$this->get('/photo/0_6.png')
->assertNotFound()
->assertHeader('X-Skinbase-Session', 'skipped');
$this->head('/photo/0_6.png')
->assertNotFound()
->assertHeader('X-Skinbase-Session', 'skipped');
});
it('starts session for /photo/* when a session cookie is already present', function (): void {
$cookie = (string) config('session.cookie');
$this->withCookie($cookie, 'existing-session-cookie')
->get('/photo/0_6.png')
->assertNotFound()
->assertHeader('X-Skinbase-Session', 'started');
});
it('does not record presence for /photo/* requests', function (): void {
$this->mock(OnlineVisitorRepository::class, function ($mock): void {
$mock->shouldReceive('track')->never();
});
$this->get('/photo/0_6.png')->assertNotFound();
$this->head('/photo/0_6.png')->assertNotFound();
});