WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: WP Super Cache] Too many files causes problems (11 posts)

  1. niska
    Member
    Posted 3 years ago #

    I have more than 50000 posts. I’ve enabled “WP Cache and Super Cache enabled = ON” and “Super Cache Compression = ON”. ALL other settings are unchecked. I'm only caching posts and have set expire time to 0 seconds (never expire).

    When 30000 - 35000 posts are in the cache I get problems:

    Dynamic page generated in 2.014 seconds.
    File not cached! Super Cache Couldn’t write to: wp-content/cache/supercache/www.domain.com/my-post.html/2599829494be928f16172d0.14739459.tmp

    At this time my disk has 16 GB free. After clearing the cache, everything works again.

    My guess is that there are too many files in the supercache directory.

    Would it be possible to change the cache directory structure so that “12345.html” would go into /1/2/3/4/12345.html ?

    http://wordpress.org/extend/plugins/wp-super-cache/

  2. Donncha O Caoimh
    Member
    Posted 3 years ago #

    If you know how to get mod_rewrite to serve a file like that I'd gladly change the plugin as it would be very useful! I don't know how to do it unfortunately.

    If you're using the preload function, you'll have to cache less posts, otherwise, set your expiry time smaller so that number of posts aren't cached.

    It's a filesystem issue unfortunately. You could also change your permalinks and add a mod_rewrite rule to redirect with a 301 redirect. You won't lose any pagerank that way.

  3. niska
    Member
    Posted 3 years ago #

    This checks to see if the URL has more than 4 characters. If so it rewrites using the subdirectory:

    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/$2/$3/$4/index.html.gz -f
    RewriteRule ^([a-zA-Z0-9])([a-zA-Z0-9])([a-zA-Z0-9])(.+) /wp-content/cache/supercache/%{HTTP_HOST}/$1/$2/$3/$4/index.html.gz [L]

    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/$2/$3/$4/index.html -f
    RewriteRule ^([a-zA-Z0-9])([a-zA-Z0-9])([a-zA-Z0-9])(.+) /wp-content/cache/supercache/%{HTTP_HOST}/$1/$2/$3/$4/index.html [L]

    Since there might be URLs that are less than 4 characters long, you still need to keep the old rewrite-rules.

  4. niska
    Member
    Posted 3 years ago #

    Did you get any time to have a look at this?

  5. Donncha O Caoimh
    Member
    Posted 3 years ago #

    Thanks for those, no I haven't had time to look at this right now, and won't for a few days.

  6. Donncha O Caoimh
    Member
    Posted 3 years ago #

    Oh, it's unlikely something like this will go into the next version. It will make cache generation and maintenance a lot more complicated. :(

  7. Ian
    Member
    Posted 3 years ago #

    For the layman, is there a maximum for what supercache will work with? I'm intending to have a lot of posts and custom post types in the longrun

    Does each custom post type go into a different cache folder?

  8. Donncha O Caoimh
    Member
    Posted 3 years ago #

    If you use a permalink structure like /yyyy/dd/postname/ you can probably have as many posts as you want but if you only use /postname/ then you'll be limited to whatever your server's filesystem can handle. That differs from operating system to operating system, and filesystem.

    ext2/ext3 on Linux can hold 32,000 files or directories in a directory. So you can have 31,998 posts cached. The other 2 files will be the cached copies of the front page, gzipped and not gzipped.

    I'm not sure about other filesystems.

    I blogged about this in the announcement post for the latest version of the plugin.

  9. Ian
    Member
    Posted 3 years ago #

    So since I use /category/postname/ I should be fine, because I don't have more than a couple thousand in any category?

  10. Donncha O Caoimh
    Member
    Posted 3 years ago #

    Yes.

  11. Ian
    Member
    Posted 3 years ago #

    Great, thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic