Body: <p>We are implementing fast CGI cache (not not the proxy version) but it seems that our upstream cache hit is always MISS. If we hijack <code>public/index.php</code> by not running <code>require_once($craftPath."/vendor/autoload.php");</code> and simply echo time the cache gets created and hit. We noticed that Craft adds cache control, pragma and expires headers by default. We tell FastCGI to ignore the headers with no luck.</p>
  
  <p>Does Craft do anything to not allow FastCGI caching?</p>
  
  <p>Thanks!</p>
  
  <pre><code>location ~ \.php$ {
      fastcgi_ignore_headers X-Accel-Expires Expires Cache-Control;
      fastcgi_cache cacher;
      fastcgi_cache_valid 200 60m;
      fastcgi_cache_methods GET HEAD;
      fastcgi_split_path_info ^(.+\.php)(/.+)$;
      fastcgi_pass 127.0.0.1:9000;
      fastcgi_index index.php;
      include fastcgi_params;
      fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
  }
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-09T18:09:16.307Z
Comments.Text: Did you ever figure the out? You also need to hide Craft's default cookie otherwise nginx won't hit the cache. Something like  ``fastcgi_hide_header Set-Cookie`` will work.
Comments.UserDisplayName: RitterKnight
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-05T00:23:11.200Z
Comments.Text: @RitterKnight I've been exploring using `fastcgi_hide_header Set-Cookie` which does exactly what I need. The problem is, I can't seem to figure out how to do it conditionally. For example, we don't want to strip the `Set-Cookie` headers if we aren't serving it up from the cache (otherwise things like the AdminCP can't set their session cookies). Any thoughts?
Comments.UserDisplayName: andrew.welch
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-05T14:22:12.173Z
Comments.Text: One thing that works out of the box is to duplicate Craft's ``index.php`` file and name it whatever you want, like ``indexadmin.php``. Make a location block that corresponds to the cp trigger and point requests at that file for backend and front end requests at the regular craft index.php. A slightly cleaner way that works within an if block or location block is the 3rd party ``more_clear_headers`` module. If you use ubuntu/debian it's bundled with some PPAs of nginx (the nginx-extras package iirc).
Comments.UserDisplayName: RitterKnight
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-14T19:20:48.240Z
Comments.Text: I just learned that Craft 3 is going to be [configurable](http://craftcms.stackexchange.com/a/18504/1016) so it won't set a session unless it needs one. This is going to be a big boon in this respect.
Comments.UserDisplayName: RitterKnight
Tags: <cache><nginx>
Title: Nginx FastCGI caching NO PROXY
ThreadText: # Nginx FastCGI caching NO PROXY
  
  (Asked by: username_0 on 2015-09-10)
  
  We are implementing fast CGI cache (not not the proxy version) but it seems that our upstream cache hit is always MISS. If we hijack `public/index.php` by not running `require_once($craftPath."/vendor/autoload.php");` and simply echo time the cache gets created and hit. We noticed that Craft adds cache control, pragma and expires headers by default. We tell FastCGI to ignore the headers with no luck.
  
  Does Craft do anything to not allow FastCGI caching?
  
  Thanks!
  
  ```
  location ~ \.php$ {
      fastcgi_ignore_headers X-Accel-Expires Expires Cache-Control;
      fastcgi_cache cacher;
      fastcgi_cache_valid 200 60m;
      fastcgi_cache_methods GET HEAD;
      fastcgi_split_path_info ^(.+\.php)(/.+)$;
      fastcgi_pass 127.0.0.1:9000;
      fastcgi_index index.php;
      include fastcgi_params;
      fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
  }
  
  ```
  
  **Tags:** cache, nginx
  
  > **Comments:**
  > **username_1**: Did you ever figure the out? You also need to hide Craft's default cookie otherwise nginx won't hit the cache. Something like  ``fastcgi_hide_header Set-Cookie`` will work.  
  > **username_2**: @username_1 I've been exploring using `fastcgi_hide_header Set-Cookie` which does exactly what I need. The problem is, I can't seem to figure out how to do it conditionally. For example, we don't want to strip the `Set-Cookie` headers if we aren't serving it up from the cache (otherwise things like the AdminCP can't set their session cookies). Any thoughts?  
  > **username_1**: One thing that works out of the box is to duplicate Craft's ``index.php`` file and name it whatever you want, like ``indexadmin.php``. Make a location block that corresponds to the cp trigger and point requests at that file for backend and front end requests at the regular craft index.php. A slightly cleaner way that works within an if block or location block is the 3rd party ``more_clear_headers`` module. If you use ubuntu/debian it's bundled with some PPAs of nginx (the nginx-extras package iirc).  
  > **username_1**: I just learned that Craft 3 is going to be [configurable](http://craftcms.stackexchange.com/a/18504/1016) so it won't set a session unless it needs one. This is going to be a big boon in this respect.  
  
  ---
  
  ## 0 answers
  
  