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

Jack
  • 857
  • 14
  • 39

1 Answers1

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.

albert
  • 4,290
  • 1
  • 21
  • 42
  • 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? – Jack Sep 13 '17 at 18:54
  • 1
    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. – albert Sep 13 '17 at 20:12
  • OMG, this is a brilliant fix! Thanks a lot again for this workaround – fire1 Jul 13 '22 at 17:12