dunglas / frankenphp

🧟 The modern PHP app server
https://frankenphp.dev
MIT License
6.78k stars 231 forks source link

Frankenphp keeps caching the response #1079

Closed ezekel closed 1 day ago

ezekel commented 3 days ago

Hi,

I have Laravel api that returns simple text when I use Postman on the first request and second request without changing the API response will reponse immediately, but when I edit the API like this 'Hello frank2'; it takes ~2-3 seconds, then if I will request again without editing it will return immediately then if I edit again it will return 2-3 seconds. I tried also my nuxt app same result it will take 2-3 seconds.

Does Frankenphp is caching my response? or is there some configuration I missed?

Route::get('/books', function (Request $request) {
    return 'Hello frank1';
})->middleware('auth:sanctum');

here is my docker-compose

    php:
        container_name: larabells.local
        build:
            context: .
            dockerfile: ./docker/web.dockerfile
        image: larabells

        ports:
            - "80:80"
            - "8000:8000"
            - "443:443"
            - "443:443/udp" # HTTP/3
            - "5173:5173"
        volumes:
            - .:/app

        entrypoint: php artisan octane:frankenphp  --watch   --workers=1 --max-requests=1000 --host=larabells.local --port=80  --admin-port=2019
        environment:
            - SERVER_NAME=larabells.local
        env_file:
            - ./.env

In postman test

image

Thank you in advance

AlliBalliBaba commented 2 days ago

Laravel Octane will run FrankenPHP in it's worker mode. Since the worker mode is a long running process and doesn't instantly reflect changes to your files, Laravel uses chokidar to restart the whole process on file changes (if you pass the --watch flag). Restarting the process like this tends to be slow and can take some seconds, sometimes it will even crash the process (at least in my experience).

In the next minor version, FrankenPHP will probably have a built in watcher mode that should be more performant and you also won't need npm.

ezekel commented 1 day ago

Thank you for that info