I have the folowing niginx config file:

server {
    listen       80;
    server_name  pajilleros.com www.pajilleros.com;
    access_log off;

    location / {
        root   /home/website/public_html;
    index /silex/web/index.php;
    try_files $uri $uri/ /rewrite.php?$args;

    # Rewrite to another folder
    location /themes {
    rewrite ^/themes/(.*) /silex/web/themes/$1;

    #Rewrite of page
    location /some-page {
        try_files $uri $uri/ /silex/web/index.php;
    location /another-page {
        try_files $uri $uri/ /silex/web/index.php;

    #error_page  404              /404.html;

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;

location ~ \.php$ {

        root           /home/website/public_html;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
        include        fastcgi_params;

    fastcgi_buffers 256 16k; 
    fastcgi_buffer_size 128k; 
    fastcgi_connect_timeout 5s; 
    fastcgi_send_timeout 120s; 
    fastcgi_read_timeout 120s; 
    fastcgi_busy_buffers_size 256k; 
    fastcgi_temp_file_write_size 256k; 
    reset_timedout_connection on; 



I want to cache the pages /some-page and /another-page as static 30 seconds, but i only know how to make cache with proxy_pass, in this case, i'm not using proxy_pass, only php-fpm.

I can do it with nginx ? or i have to use varnish as a cache ?

Thanks !


Yes you can do it with Nginx. Use FastCGI cache for it. Here is one of many tutorials how to do it:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.