2

I am using php Symfony 3 on my site and when I try to make a long ajax request, it blocks my site from operation with my browser. It means that I even cannot retrieve a page from another browser tab until request is done. On another server, which is written on pure php there is no such issue (I can open another page from my site when ajax call is pending). I thought this would be a mod_rewrite issue, but dont know how to check it. Are there any ideas how to fix it? Thank you.

UPD_1 I came across THIS question and now if the issue is with session file lock, how it could be fixed in Symfony 3 environment? Thank you

1

1 Answer 1

4

Close your session in your controller.

public function yourAjaxAction() {
    $this->get("session")->save();
    ...
}

This will make your session readonly and you will be able to do another requests. Only do that on the requests that does not need to update your session.

Sign up to request clarification or add additional context in comments.

3 Comments

what does it mean update your session? When does session get updated? Will it make session writable on another ajax calls (to different ajax actions) or I need to make it writable explicitly?
The session will be writable on other calls but not on the one you already are after calling session->save . if you need to do something on the session do it before that call. You update the session when you add, delete or modify data from your session. Example: When you use the flash bag message controller, modify your session using the session service or indirectly when you do login, logout, impersonate a user. There is many uses for sessions, I just give you a short list.
OMG, this is a brilliant fix! Thanks a lot again for this workaround

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.