# Managing static file generated by PHP CMS

**URL:** <https://www.ruby-forum.com/t/managing-static-file-generated-by-php-cms/201398>\
**Category:** NGINX\
**Created:** [January 6, 2011, 6:50pm UTC](https://www.ruby-forum.com/t/managing-static-file-generated-by-php-cms/201398 "2011-01-06T18:50:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [January 6, 2011, 6:50pm UTC](https://www.ruby-forum.com/t/managing-static-file-generated-by-php-cms/201398/1 "2011-01-06T18:50:43Z")

</div>

Hello everybody,

I am looking for suggestions to accomplish what I would like to achieve.

Suppose we have a PHP based CMS which could generate a static file copy  
of a HTML page, every time nginx access it via fastcgi. I think the  
basic configuration on nginx would be like below:

try\_files $uri @cms;

location @cms {  
fastcgi\_pass unix:/tmp/fastcgi.socket;  
}

The problem would be that nginx will always serve the static file until  
it gets purged. So that if the CMS updated the HTML page, the client  
will never get that new version. Is there any way to do that purging or  
update mechanism in nginx? Or should that be done by the CMS or external  
cron like program?

Would it not be the same situation if we would use fastcgi\_store  
directive?

Thanks in advance for your response.

Kind regards,

Anto

---

<div class="post-metadata">

**Author:** ![Anto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/59ef9b/32.png) [@Anto](https://www.ruby-forum.com/u/Anto)\
**Post date:** [January 7, 2011, 11:11am UTC](https://www.ruby-forum.com/t/managing-static-file-generated-by-php-cms/201398/2 "2011-01-07T11:11:10Z")

</div>

Hello, Anto:

That the way we use to solve what you encountered:  
Compile nginx with ‘cache\_purge’ module (module:  
[FRiCKLE Labs / nginx / ngx\_cache\_purge](http://labs.frickle.com/nginx_ngx_cache_purge/))  
Use ‘proxy\_cache’ to store the generated static file instead of  
‘proxy\_store’, and when the file changed, the application server(CMS, I  
think in your app) will purge that file actively.  
Part of the configure file:

proxy\_cache\_path /cache/proxy\_cache\_dir levels=2:2  
keys\_zone=cache\_one:500m  
inactive=3d max\_size=100g;  
location ~ /purge(/.\*)  
{  
allow 127.0.0.1;  
allow 192.168.1.0/24;  
deny all;  
proxy\_cache\_purge cache\_one $1;  
}

Hope it helps.

---

<div class="post-metadata">

**Author:** ![Anto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/59ef9b/32.png) [@Anto](https://www.ruby-forum.com/u/Anto)\
**Post date:** [January 10, 2011, 1:08am UTC](https://www.ruby-forum.com/t/managing-static-file-generated-by-php-cms/201398/3 "2011-01-10T01:08:56Z")

</div>

Thanks eagle sbc.

I am on VPS with quite minimum resources. So I use very little number of  
modules, which does not include HttpProxyModule. And to be honest with  
you, I still have problems making my application does what I want.

I have been thinking to utilise what ever my nginx setup could give me,  
to save the time of a novice programmer like me, in developing and  
debugging the application. It could be that utilising “fastcgi\_store”  
directive would be enough for my purpose. As every time my application  
updates a page via fastcgi, the corresponding static file will be  
automatically updated as well.

The only thing that I am not sure of is, whether the “try\_files”  
directive respects the “If-Modified-Since” request header or not. And I  
am not sure if there would be mechanism related to the “try\_files”, to  
compare “If-Modified-Since” and file’s time stamp of the updated file.  
So that in the end nginx will return the updated file with “200” status  
code, instead of just returning “304” status code as “try\_files” just  
checks the existence of the file. I guess I have to experiment myself to  
figure that out. But it would be great if somebody could confirm this.

Kind regards,

Anto
