# Wordpress permalink and cache help

**URL:** <https://www.ruby-forum.com/t/wordpress-permalink-and-cache-help/224570>\
**Category:** NGINX\
**Created:** [November 17, 2012, 6:35am UTC](https://www.ruby-forum.com/t/wordpress-permalink-and-cache-help/224570 "2012-11-17T06:35:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [November 17, 2012, 6:35am UTC](https://www.ruby-forum.com/t/wordpress-permalink-and-cache-help/224570/1 "2012-11-17T06:35:25Z")

</div>

Hello, I have a wordpress website and want to enable caching. My  
configuration below is working if no pretty url E.g.

> **[Website Domain Names, Online Stores & Hosting](https://www.domain.com/?page_id=2)**
>
> Finding the perfect website domain is as easy as 1-2-3. Buy a domain name, build and host a website, and enjoy our professional online marketing tools.

But when I use pretty url, the cache doesnt work: E.g.  
[http://domain.com/sample-page](http://domain.com/sample-page)

But the pages displays correctly for both cases.

Thank you

```
fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=microcache:5m
max_size=1000m;

server {
    listen 80;
    server_name domain.com www.domain.com;

    access_log /var/log/nginx/website.access_log;
    error_log /var/log/nginx/website.error_log;

    root /home/jon/temp/php/domain.com;
    index index.php index.htm index.html;

    location ~ .php$ {
        set $no_cache "";
        if ($request_method !~ ^(GET|HEAD)$) {
            set $no_cache "1";
        }
        if ($no_cache = "1") {
            add_header Set-Cookie "_mcnc=1; Max-Age=2; Path=/";
            add_header X-Microcachable "0";
        }
        if ($http_cookie ~* "_mcnc") {
                    set $no_cache "1";
        }
        fastcgi_no_cache $no_cache;
        fastcgi_cache_bypass $no_cache;
        fastcgi_cache microcache;
        fastcgi_cache_key $server_name|$request_uri;
        fastcgi_cache_valid 404 30m;
        fastcgi_cache_valid 200 10s;
        fastcgi_max_temp_file_size 1M;
        fastcgi_cache_use_stale updating;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_pass_header Set-Cookie;
        fastcgi_pass_header Cookie;
        fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME 
$document_root$fastcgi_script_name;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED 
$document_root$fastcgi_path_info;
        include fastcgi_params;
    }

    location ~ \.(js|css|ico|png|jpg|jpeg|gif|swf|xml|txt)$ {
  access_log off;
        expires 30d;
    }

    location ~*
\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_
{
  return 444;
    }

    location ~ /\. {
  return 444;
  access_log off;
  log_not_found off;
    }

    location ~* \.(pl|cgi|py|sh|lua)\$ {
  return 444;
    }

    location ~* (roundcube|webdav|smtp|http\:|soap|w00tw00t) {
  return 444;
    }

    location / {
  try_files $uri $uri/ /index.php;
    }
}
```

Posted at Nginx Forum:

> **[Wordpress permalink and cache help](https://forum.nginx.org/read.php?2,232940,232940#msg-232940)**
>
> Hello, I have a wordpress website and want to enable caching. My configuration below is working if no pretty url E.g. http://domain.com/?page\_id=2 But when I use pretty url, the cache doesnt work: E.g. http://domain.com/sample-page But the pages...
