Title: Page cache not cleared on HTTPS urls on editing
Last modified: August 30, 2016

---

# Page cache not cleared on HTTPS urls on editing

 *  [kevcampb](https://wordpress.org/support/users/kevcampb/)
 * (@kevcampb)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/page-cache-not-cleared-on-https-urls-on-editing/)
 * There is a bug in the page cache when working with https URLs. When saving pages
   via the editor interface, the system will attempt to clear the cache for the 
   affected page. Because of an error in a strcmp, https urls will yield the wrong
   key and the existing cache entries will not be deleted.
 * Patch for fix as follows:
 * — wp-content/plugins/w3-total-cache/lib/W3/PgCache.php.orig 2015-09-13 05:43:
   45.917016000 +0000
    +++ wp-content/plugins/w3-total-cache/lib/W3/PgCache.php 
   2015-09-13 05:43:49.461016000 +0000 @@ -958,7 +958,7 @@ $encryption = ”, $compression
   = ”, $content_type = ”, $request_uri = ”) {
 *  if ($request_uri)
    – $key = substr($request_uri, strtolower(substr($request_uri,
   0, 8)) == ‘https’ ? 8: 7); + $key = substr($request_uri, strtolower(substr($request_uri,
   0, 5)) == ‘https’ ? 8: 7); else $key = $this->_request_host . $this->_request_uri;
 * [https://wordpress.org/plugins/w3-total-cache/](https://wordpress.org/plugins/w3-total-cache/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Gravitate](https://wordpress.org/support/users/gravitate/)
 * (@gravitate)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/page-cache-not-cleared-on-https-urls-on-editing/#post-6540404)
 * Thanks kevcampb,
    This is currently a bug with version 9.4.1
 * I think it should stay at 8, but the creator forgot to include the “://” in the
   search.
 * So use this instead:
 *     ```
       $key = substr($request_uri, strtolower(substr($request_uri, 0, 8)) == 'https://' ? 8 : 7);
       ```
   
 * Changing this resolved the issue for us.
 * Also once you resolve this you also need to make sure that you also have page.
   cache.ssl = true in your settings.
 *  [midihead](https://wordpress.org/support/users/midihead/)
 * (@midihead)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/page-cache-not-cleared-on-https-urls-on-editing/#post-6540421)
 * I am experiencing the same problem with W3 Total Cache and HTTPS URLs. My whole
   site is HTPS.
 * **Gravitate**, please forgive my lack of knowledge in asking this but does the
   above patch code just get added to the PgCache.php file or is there specific 
   code in the file that needs to be updated with this?
 * Also, where do i find the “settings” you mentioned to set page.cache.ssl = true?
 * Thank you very much.
 *  [midihead](https://wordpress.org/support/users/midihead/)
 * (@midihead)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/page-cache-not-cleared-on-https-urls-on-editing/#post-6540425)
 * Alrighty then. So here’s the simple answer. I just did this and now my cache 
   is cleared when changes are saved in the WP admin dashboard:
 * 1. Open
 *     ```
       wp-content/plugins/w3-total-cache/lib/W3/PgCache.php
       ```
   
 * 2. Find this code:
 *     ```
       function _get_page_key($mobile_group = '', $referrer_group = '',<br />
               $encryption = '', $compression = '', $content_type = '', $request_uri = '') {</p>
       <p>        if ($request_uri)<br />
                   $key = substr($request_uri, strtolower(substr($request_uri, 0, 8)) == 'https://' ? 8: 7);<br />
               else<br />
                   $key = $this->_request_host . $this->_request_uri;
       ```
   
 * 3. Change this line:
 *     ```
       $key = substr($request_uri, strtolower(substr($request_uri, 0, 8)) == 'https' ? 8: 7);
       ```
   
 * to:
 *     ```
       $key = substr($request_uri, strtolower(substr($request_uri, 0, 8)) == 'https://' ? 8: 7);
       ```
   
 *  and save.
 * 4. In W3 Total Cache Page Cache settings, make sure that **Cache SSL (https) 
   requests** is checked.
 * Thanks to **kevcampb** and **Gravitate** for leading me to this fix. I’m hoping
   that the developer will correct this is the next version.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Page cache not cleared on HTTPS urls on editing’ is closed to new replies.

 * ![](https://ps.w.org/w3-total-cache/assets/icon-256x256.png?rev=1041806)
 * [W3 Total Cache](https://wordpress.org/plugins/w3-total-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/w3-total-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/w3-total-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/w3-total-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/w3-total-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/w3-total-cache/reviews/)

## Tags

 * [cache](https://wordpress.org/support/topic-tag/cache/)
 * [clearing](https://wordpress.org/support/topic-tag/clearing/)
 * [HTTPS](https://wordpress.org/support/topic-tag/https/)

 * 3 replies
 * 3 participants
 * Last reply from: [midihead](https://wordpress.org/support/users/midihead/)
 * Last activity: [10 years, 4 months ago](https://wordpress.org/support/topic/page-cache-not-cleared-on-https-urls-on-editing/#post-6540425)
 * Status: not resolved