D
D
dimonfreeman2021-04-12 17:51:44
Yii
dimonfreeman, 2021-04-12 17:51:44

How, when pageCache was enabled, ajax form was sent more than once?

The situation is as follows pageCache
'pageCache' => [
'class' => 'yii\filters\PageCache',
'only' => ['index'], // open the cache of which method
'duration' => 86400, / / cache valid time, in seconds, is set to 0 for never expire
'enabled' => true, // whether to enable page caching
'variations' => array_merge(Yii::$app->request->get(), [
Yii::$app->request->isAjax,
]),
],

and there is an ajax form on the page, after the first submission the submission doesn't work anymore...
i.e. it caches + submits the form after it doesn't submit the form and doesn't record the request ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2021-04-14
@rpsv

So why are you sending a request to a cached page, the application has written the AJAX variant to the cache, and without AJAX, that's one send. Place the AJAX request handler in a non-cached action and you'll be fine.
-
PS Why make page cache variations dependent on GET? Any parameter will create a new entry in the cache and it will oh how inflate its size.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question