I ran into a strange problem. All forms are cached for anonymous users even if there is a token present in the url. But I need that token to store a "value" field type on a form. Because the form is stored in cache, it does not verify for that get param and set the value accordingly.

I tried using an "after_build" function but that is also not triggered.

Is there a way I can use the GET param in my code? Or is there a way I can disable caching only for this form?


2 Answers 2


Have a look at this module Cache Exclude, it might help you.

And even have look at this link, it is having more details about your problem.

  • I saw that page also, couldn't use the information there. I haven't tried cache exclude either because I found the problem before that. My form was generated as a block and the block was cached. I had to add cache = DRUPAL_NO_CACHE to the block info function. Commented Apr 5, 2016 at 8:58
  • Good, I am not aware of that it is block form, I thought that its is a normal menu callback, so I suggested this Cache Exclude module
    – NTT
    Commented Apr 5, 2016 at 9:08

I found my answer. My form was part of a block that was being cached by Drupal. I had to add "cache" = DRUPAL_NO_CACHE to the block info function to stop the block from being cached. After that, everything worked as expected.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.