WordPress.org

Ready to get started?Download WordPress

Forums

WP Super Cache
WP Super Cache Statistics - Cache Hits vs. Misses (7 posts)

  1. dvmorris
    Member
    Posted 3 years ago #

    Is there a functionality in WP Super Cache that can track cache hits vs. cache misses?

    Thanks,
    Dave

  2. Donncha O Caoimh
    Member
    Plugin Author

    Posted 3 years ago #

    Not directly, but you can use Google Analytics to record cache hits and cache misses. I did it some time last year but forget how now.

  3. dvmorris
    Member
    Posted 3 years ago #

    Would there be a way to accomplish this by looking at apache access logs?

    Dave

  4. bmorneau
    Member
    Posted 3 years ago #

    I was looking in wp-cache-phase1.php where it checks to see if the file exists in the cache, would it be a viable patch to incorporate a counter that just kept track of the total number of hits/misses for that cache?

  5. Donncha O Caoimh
    Member
    Plugin Author

    Posted 3 years ago #

    You could possibly modify that file if you're using PHP mode caching, but if it's mod rewrite then it won't show cache hits.

    Be careful about collecting stats. Do an error_log() to a file and process it later. Don't send it directly to a database table.

  6. bmorneau
    Member
    Posted 3 years ago #

    If I clear my browser cache and remove the blog/ and supercache/ directories, and then reload the webpage, this re-creates the blog/ and supercache/ directories and saves the index.html. Now if I refresh it again, there is a check in the code that looks for this index.html and if found uses it instead of reloading the page from scratch. Where is this check in the wp super cache code?

    I have placed error_log statements in each function in wp-cache-phase1 and wp-cache-phase2. When I read the error log, I get the correct output when I do the first page refresh that caches the html file, but when I refresh it again none of the error_log statements are hit.

  7. Donncha O Caoimh
    Member
    Plugin Author

    Posted 3 years ago #

    The function is wp_cache_serve_cache_file but if you're using mod_rewrite caching then no php will be executed when a cached page is served. That's why I used Google Analytics to track this. I think I used two goals to track them.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic