How to set up Varnish caching for GraphQL in Django

Here is my django-benchmark project in which I implemented simple REST API and GraphQL endpoints. In front of my application I put Varnish for caching. Caching works well for Rest HTTP endpoints and does not work for GraphQL here is my Varnish configuration. What am I doing wrong?

vcl 4.1;

# Default backend definition. Set this to point to your content server.
backend default {
    .host = "";
    .port = "8080";

sub vcl_hash {
    # For multi site configurations to not cache each other's content
    if ( {
    } else {

    if (req.url ~ "/api/graphql") {
        call process_graphql_headers;

sub process_graphql_headers {
    if (req.http.Store) {
    if (req.http.Content-Currency) {

sub vcl_recv {
    # Authenticated requests should not be cached by default
    if (req.http.Authorization ~ "^Bearer") {
        return (pass);

sub vcl_backend_response {

sub vcl_deliver {

Read more here:

Content Attribution

This content was originally published by Lukasz Dynowski at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: