Fix CSRF token generation when cache is enabled, should solve #632