# FastCGI with Caching & JSONP -\> Caching problem

**URL:** <https://www.ruby-forum.com/t/fastcgi-with-caching-jsonp-caching-problem/189855>\
**Category:** NGINX\
**Created:** [June 8, 2010, 11:13pm UTC](https://www.ruby-forum.com/t/fastcgi-with-caching-jsonp-caching-problem/189855 "2010-06-08T23:13:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcmaxx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@mcmaxx](https://www.ruby-forum.com/u/mcmaxx)\
**Post date:** [June 8, 2010, 11:13pm UTC](https://www.ruby-forum.com/t/fastcgi-with-caching-jsonp-caching-problem/189855/1 "2010-06-08T23:13:32Z")

</div>

Hello,

We’re currently running a server on nginx and fastCGI with caching  
enabled.

The problem is, the javascript requesting the .php files from nginx w/  
fastCGI needs to used JSONP since it’s cross-site.

We’re noticing that since the /?jsonp=#### is randomized every call our  
fastCGI is not properly caching the request.

Can you please help out and direct me into perhaps tellings nginx to  
ignore any values set by the ?jsonp?

We use REST architecture so the ?jsonp= is the only GET variable we deal  
with.

Here is our nginx - caching setup

```auto
#fastcgi caching
    fastcgi_cache_path /var/cache/nginx levels=1:2
    keys_zone=ABC:10m
    inactive=5m ;
```

```
        [code]
        fastcgi_cache TWEET;
        fastcgi_cache_valid 200 302 1m;
        fastcgi_cache_valid 301 1m;
        fastcgi_cache_valid any 1m;
        fastcgi_cache_min_uses 1;
        fastcgi_cache_use_stale error timeout invalid_header 

```

http\_500;  
fastcgi\_cache\_key 127.0.0.1:9000$request\_uri;  
[/code]

Much appreciated!

Posted at Nginx Forum:

> **[FastCGI with Caching & JSONP -\> Caching problem](https://forum.nginx.org/read.php?2,96081,96081#msg-96081)**
>
> Hello, We're currently running a server on nginx and fastCGI with caching enabled. The problem is, the javascript requesting the .php files from nginx w/ fastCGI needs to used JSONP since it's cross-site. We're noticing that since the /?jsonp=####

---

<div class="post-metadata">

**Author:** ![mcmaxx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@mcmaxx](https://www.ruby-forum.com/u/mcmaxx)\
**Post date:** [June 8, 2010, 11:17pm UTC](https://www.ruby-forum.com/t/fastcgi-with-caching-jsonp-caching-problem/189855/2 "2010-06-08T23:17:38Z")

</div>

OOPS the ABC should be TWEET, see below

```auto
#fastcgi caching
fastcgi_cache_path /var/cache/nginx levels=1:2
keys_zone=TWEET:10m
inactive=5m ;
```

Posted at Nginx Forum:

> **[Re: FastCGI with Caching & JSONP -\> Caching problem](https://forum.nginx.org/read.php?2,96081,96085#msg-96085)**
>
> Hello, We're currently running a server on nginx and fastCGI with caching enabled. The problem is, the javascript requesting the .php files from nginx w/ fastCGI needs to used JSONP since it's cross-site. We're noticing that since the /?jsonp=####

---

<div class="post-metadata">

**Author:** ![mcmaxx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@mcmaxx](https://www.ruby-forum.com/u/mcmaxx)\
**Post date:** [June 8, 2010, 11:31pm UTC](https://www.ruby-forum.com/t/fastcgi-with-caching-jsonp-caching-problem/189855/3 "2010-06-08T23:31:41Z")

</div>

Hello!

On Tue, Jun 08, 2010 at 05:13:04PM -0400, mcmaxx wrote:

> nginx to ignore any values set by the ?jsonp?
> 
> We use REST architecture so the ?jsonp= is the only GET variable  
> we deal with.

Using ssi filter or sub filter for jsonp substitution and  
fastcgi\_cache\_key without jsonp= argument should do the trick.

Maxim D.

---

<div class="post-metadata">

**Author:** ![mcmaxx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@mcmaxx](https://www.ruby-forum.com/u/mcmaxx)\
**Post date:** [June 8, 2010, 11:52pm UTC](https://www.ruby-forum.com/t/fastcgi-with-caching-jsonp-caching-problem/189855/4 "2010-06-08T23:52:10Z")

</div>

Hi!

I fixed the problem, in case anyone cares

```auto
fastcgi_cache_key 127.0.0.1:9000$fastcgi_script_name;
```

Is the new key

Posted at Nginx Forum:

> **[Re: FastCGI with Caching & JSONP -\> Caching problem](https://forum.nginx.org/read.php?2,96081,96100#msg-96100)**
>
> Hello, We're currently running a server on nginx and fastCGI with caching enabled. The problem is, the javascript requesting the .php files from nginx w/ fastCGI needs to used JSONP since it's cross-site. We're noticing that since the /?jsonp=####
