# Different fastcgi\_cache for bots and humans

**URL:** <https://www.ruby-forum.com/t/different-fastcgi-cache-for-bots-and-humans/235749>\
**Category:** NGINX\
**Created:** [July 12, 2013, 10:23pm UTC](https://www.ruby-forum.com/t/different-fastcgi-cache-for-bots-and-humans/235749 "2013-07-12T22:23:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [July 12, 2013, 10:23pm UTC](https://www.ruby-forum.com/t/different-fastcgi-cache-for-bots-and-humans/235749/1 "2013-07-12T22:23:22Z")

</div>

As mentioned before, I’m tweaking pixabay’s version of handling the new  
Google Image search traffic killer by making their trap URLs more  
cacheable.

Img tags in the html will have ?i appended to the source and those “?i”  
are removed for bots. I thought I could use nginx’s httpsubmodule to  
strip  
the ?i for bots, but I’d still like it cacheable, with one version for  
humans and one for bots.

Doing some digging I came across an idea like this:

map $http\_user\_agent $botornot {  
default ‘human’;  
~(Googlebot|Bing|other|bit|names) ‘bot’;  
}

I’m assuming I could then use $botornot in the fastcgi\_cache\_key? If so,  
where would I place it in my current line, which is:

fastcgi\_cache\_key “$scheme$request\_method$host$uri?$args”;

Thanks.
