• Hello

    I’m using WP Super Cache version 0.9.9.9 (latest). My WordPress website does not require or make use of posts or comments – it is strictly serving a static based website using pages. The /wp-admin/ is of course used to administrate the website.

    My current theme utilises AJAX but requests pages using POST method. Through this, the page content received is slightly different to what would be delivered by directly access a page (as expected).

    The first step I took was to remove the 4 entries comprising of REQUEST_METHOD and QUERY_STRING in the .htaccess file. Clearing the plugins cache and subsequently loading the pages via AJAX still does not generate a cached page when I regenerated cache stats in the plugins GUI nor did the file exist in wp-content/cache/supercache/*.

    The second step was to modify the theme. I replaced all instances of $_POST with $_GET and made similar changes to the JavaScript files. After the modifications, when I loaded a page via AJAX, it would load the entire contents of the page, rather than the AJAX friendly content – resulting in duplicate menus and so on. Obviously I must have missed something but instead of wasting any more time on that I realised I have already deployed this theme for several different websites and in my eyes it doesn’t make sense to modify it.

    This is all to be expected as the plugin (or any other cache plugin) isn’t really designed for this kind of work. So what I would like is assistance or guidance on modifying the plugin to generate separate cached pages for direct access and for those loaded through AJAX POST. Any assistance would be greatly appreciated.

    Below is the original .htaccess entry for WP Super Cache:

    # BEGIN WPSuperCache
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    AddDefaultCharset UTF-8
    RewriteCond %{REQUEST_URI} !^.*[^/]$
    RewriteCond %{REQUEST_URI} !^.*//.*$
    RewriteCond %{REQUEST_METHOD} !POST
    RewriteCond %{QUERY_STRING} !.*=.*
    RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$
    RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\”]+ [NC]
    RewriteCond %{HTTP:Profile} !^[a-z0-9\”]+ [NC]
    RewriteCond %{HTTP:Accept-Encoding} gzip
    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz -f
    RewriteRule ^(.*) “/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz” [L]

    RewriteCond %{REQUEST_URI} !^.*[^/]$
    RewriteCond %{REQUEST_URI} !^.*//.*$
    RewriteCond %{REQUEST_METHOD} !POST
    RewriteCond %{QUERY_STRING} !.*=.*
    RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$
    RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\”]+ [NC]
    RewriteCond %{HTTP:Profile} !^[a-z0-9\”]+ [NC]
    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f
    RewriteRule ^(.*) “/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html” [L]
    </IfModule>

    # END WPSuperCache

    https://www.ads-software.com/extend/plugins/wp-super-cache/

  • The topic ‘[Plugin: WP Super Cache] AJAX Post’ is closed to new replies.