Score:0

Caching related to submit functions and Varnish

uy flag

I am trying to set my website ready before installing and configuring Varnish on it. For that, in lots of cases where I have php functions in .module files that include some tests about cookies if ($_COOKIE['travelID'] == 'yo'){..}, I was afraid that the page will be cached and the condition will be executed only once and then all the users will get the same result. To avoid this issue related to varnish and caching, In most cases I moved the code to javascript and put all the cookies logic there. In other cases where I couldn't reproduce the entire same logic in javascript, I simply wrote an ajax call in JS where I specified the path of a controller function that have the exact same behavior. And I kept the same php cookie condition in the controller file but I specified that this url must no be cached in the Varnish configuration. However I have one submitForm() funtion in a custom module associated with one of my custom forms. this submitForm function starts with this same cookie condition mentioned above. I was thinking that maybe submitForm functions aren't cached by default on Varnish ? Can someone confirm this ? or if this is not the case, what can I do to set this cookie condition in js or something?

cn flag
Yes, `POST` requests are typically configured to bypass cache in a reverse proxy like Varnish. You need to check your own configuration to be sure though.
uy flag
thank you so much for this clear and concise answer !
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.