• Resolved treecutter

    (@treecutter)


    Hello

    We are trying to use a custom cache folder

    Have added the below snippet before the # BEGIN WordPress section in our .htaccess file, as described here: https://www.keycdn.com/support/wordpress-cache-enabler-plugin

    Flushed all server caches etc. but the default folder ( cache-enabler ) is still created and the custom folder is not created.

    Test environment Debian 10/Buster, Apache 2.4.38, PHP 7.4.23

    Many thanks

    # BEGIN Cache Enabler
    
    <IfModule mod_rewrite.c>
        <IfModule mod_setenvif.c>
            RewriteEngine On
            RewriteBase /
    
            # cache directory
            SetEnvIf Host ^ CE_CACHE_DIR=/wp-content/cache/MY_CUSTOM_FOLDER_NAME
    
            # default cache keys
            SetEnvIf Host ^ CE_CACHE_KEY_SCHEME http-
            SetEnvIf Host ^ CE_CACHE_KEY_DEVICE
            SetEnvIf Host ^ CE_CACHE_KEY_WEBP
            SetEnvIf Host ^ CE_CACHE_KEY_COMPRESSION
    
            # scheme cache key
            RewriteCond %{HTTPS} ^(on|1)$ [OR]
            RewriteCond %{SERVER_PORT} =443 [OR]
            RewriteCond %{HTTP:X-Forwarded-Proto} =https [OR]
            RewriteCond %{HTTP:X-Forwarded-Scheme} =https
            RewriteRule ^ - [E=CE_CACHE_KEY_SCHEME:https-]
    
            # device cache key
            # SetEnvIf User-Agent "(Mobile|Android|Silk/|Kindle|BlackBerry|Opera Mini|Opera Mobi)" CE_CACHE_KEY_DEVICE=-mobile
    
            # webp cache key
            # SetEnvIf Accept image/webp CE_CACHE_KEY_WEBP=-webp
    
            # compression cache key
            # <IfModule mod_mime.c>
            #     SetEnvIf Accept-Encoding gzip CE_CACHE_KEY_COMPRESSION=.gz
            #     AddType text/html .gz
            #     AddEncoding gzip .gz
            # </IfModule>
    
            # get cache file
            SetEnvIf Host ^ CE_CACHE_FILE_DIR=%{ENV:CE_CACHE_DIR}/%{HTTP_HOST}%{REQUEST_URI}
            SetEnvIf Host ^ CE_CACHE_FILE_NAME=%{ENV:CE_CACHE_KEY_SCHEME}index%{ENV:CE_CACHE_KEY_DEVICE}%{ENV:CE_CACHE_KEY_WEBP}.html%{ENV:CE_CACHE_KEY_COMPRESSION}
            SetEnvIf Host ^ CE_CACHE_FILE=%{ENV:CE_CACHE_FILE_DIR}/%{ENV:CE_CACHE_FILE_NAME}
    
            # check if cache file exists
            RewriteCond %{DOCUMENT_ROOT}%{ENV:CE_CACHE_FILE} -f
    
            # check request method
            RewriteCond %{REQUEST_METHOD} =GET
    
            # check permalink structure has trailing slash
            RewriteCond %{REQUEST_URI} /[^\./\?]+(\?.*)?$
            # check permalink structure has no trailing slash
            # RewriteCond %{REQUEST_URI} /[^\./\?]+/(\?.*)?$
    
            # check excluded query strings
            RewriteCond %{QUERY_STRING} !^(?!(fbclid|ref|mc_(cid|eid)|utm_(source|medium|campaign|term|content|expid)|gclid|fb_(action_ids|action_types|source)|age-verified|usqp|cn-reloaded|_ga|_ke)).+$
    
            # check excluded cookies
            RewriteCond %{HTTP_COOKIE} !(wp-postpass|wordpress_logged_in|comment_author)_
    
            # deliver cache file
            RewriteRule ^ %{ENV:CE_CACHE_FILE} [L]
        </IfModule>
    </IfModule>
    
    # END Cache Enabler
Viewing 3 replies - 1 through 3 (of 3 total)
  • Anonymous User 16850768

    (@anonymized-16850768)

    The plugin itself is what creates the directories that store the cached pages. When using the advanced configuration the server will just try to find and deliver them.

    Support for overriding this actually just came out in the 1.8 branch, so great timing. ?? To do this you will need to define the CACHE_ENABLER_CACHE_DIR constant, like in your wp-config.php file (before WordPress sets up). For example:

    
    define( 'CACHE_ENABLER_CACHE_DIR', '/your/path/to/wp-content/cache/custom-folder' );
    
    
    define( 'CACHE_ENABLER_CACHE_DIR', ABSPATH . 'wp-content/cache/custom-folder' );
    

    It will need to be the full path and can be any directory that is writable. Do not include a trailing slash. If using the ABSPATH constant it has a trailing slash, so what follows doesn’t need a leading slash.

    I will be adding some documentation for the new constants here shortly.

    Thread Starter treecutter

    (@treecutter)

    Hello Corey

    Thanks, that works perfectly

    Your fast response is highly appreciated.

    This plugin is just getting better and better, litte wonder you now have over 100,000 active install, great job !!!

    Anonymous User 16850768

    (@anonymized-16850768)

    Excellent! And thank you! That is what we’ve been trying for, so hearing that is really appreciated. ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Cache Folder’ is closed to new replies.