Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

GodziLaravel's avatar

Is it possible to specify the time between each post request ?

I have a post route, I want to avoid user to send many requests , I tried to use throttle but the problem is the throttle can only set a specific number of requests per X minutes. It means if I set 10 request per minute It's possible to request 10 request in the first second only! But as I said in the title I want to set time between requests . Thnaks

0 likes
5 replies
Sergiu17's avatar
// one request per 6 seconds
->middleware('throttle:1,0.1');
GodziLaravel's avatar

@Sinnbeck Thanks so I have to change the form of this route :

  Route::resource('api/competences', 'CompetenceController', [
        'only' => ['index', 'show', 'store', 'update', 'destroy'],
    ]);

to

  Route::resource('api/competences', 'CompetenceController', [
        'only' => ['index', 'show', 'update', 'destroy'],
    ]);

Route::post('api/competences', 'CompetenceController')
->middleware('throttle:1,0.1');

Because I'm trying to find a way to add this middleware only for 'store'. the reason why I ask this is because I have too many Route::resource.

Sinnbeck's avatar

@GodziLaravel Yeah. I dont think you can add middleware to a part of a resource, so that how I would do it as well.

1 like

Please or to participate in this conversation.