diff --git a/esi.module b/esi.module
index ceb99d3..2530112 100644
--- a/esi.module
+++ b/esi.module
@@ -425,6 +425,10 @@ function esi__block_handler($bid, $page = NULL) {
 }
 
 function esi_add_cache_headers($scope, $max_age) {
+  // Nginx follows rfc2616 section 14.9.1 correctly and will not cache if
+  // header is set to private. The given Varnish VCL does not follow the RFC,
+  // and for ajax we want to use private.
+  $user_cache_control_header = variable_get('esi_mode', ESI_MODE) == ESI__CONFIG_SSI ? 'public' : 'private';
   switch ($scope) {
     // Disabled.
     case 0:
@@ -444,7 +448,7 @@ function esi_add_cache_headers($scope, $max_age) {
     case 4:
     // User Role/Page.
     case 5:
-      drupal_set_header("Cache-Control: private, max-age=$max_age");
+      drupal_set_header("Cache-Control: $user_cache_control_header, max-age=$max_age");
       drupal_set_header("X-BLOCK-CACHE: " . BLOCK_CACHE_PER_ROLE);
       break;
 
@@ -452,7 +456,7 @@ function esi_add_cache_headers($scope, $max_age) {
     case 6:
     // User ID/Page.
     case 7:
-      drupal_set_header("Cache-Control: private, max-age=$max_age");
+      drupal_set_header("Cache-Control: $user_cache_control_header, max-age=$max_age");
       drupal_set_header("X-BLOCK-CACHE: " . BLOCK_CACHE_PER_USER);
       break;
   }
