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:
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?
That the way we use to solve what you encountered:
Compile nginx with ‘cache_purge’ module (module: FRiCKLE Labs / 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:
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.