Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Currently we can only exclude pages using Drupal path, such as node/10, blog/23, etc..
Would it be easier if we can exclude pages using URL alias, such as 'my-dynamic-page'.
I have the code for it, here is the new cacheexclude_init() for file cacheexclude.module.
Added: OR drupal_match_path(substr($_SERVER['QUERY_STRING'],2), $pages)
function cacheexclude_init() {
$pages = trim(variable_get('cacheexclude_list', ''));
// If the current page is one we want to exclude from the cache,
// set the page caching to false temporarily.
//if (strlen($pages) && drupal_match_path($_GET['q'], $pages)) { //replace this with next 2 lines
if (strlen($pages) && (drupal_match_path($_GET['q'], $pages) ||
drupal_match_path(substr($_SERVER['QUERY_STRING'],2), $pages) )) {
$GLOBALS['conf']['cache'] = FALSE;
}
}
Comment | File | Size | Author |
---|---|---|---|
#9 | cacheexclude.module-alias.patch | 773 bytes | joep.hendrix |
#7 | cacheexclude.module-alias.patch.txt | 633 bytes | hongbo |
Comments
Comment #1
hongbo CreditAttribution: hongbo commentedComment #2
Crell CreditAttribution: Crell commentedCan you file a proper patch? Thanks. http://drupal.org/diffandpatch
Comment #3
hongbo CreditAttribution: hongbo commentedHere is proper patch, and it only change ONE line.
Comment #4
Crell CreditAttribution: Crell commentedDon't access $_SERVER['QUERY_STRING'] directly. That's more error-prone. It's better and more portable to call drupal_get_path_alias($_GET['q']), as that ties into the aliasing system directly.
Comment #5
hongbo CreditAttribution: hongbo commentedOk, drupal_get_path_alias($_GET['q']) works. Here is the modified patch
Comment #6
Crell CreditAttribution: Crell commentedDo not copy and paste a patch into the form. Create a patch file and attach it.
Comment #7
hongbo CreditAttribution: hongbo commentedOk, patch attached.
Comment #8
Crell CreditAttribution: Crell commentedComment #9
joep.hendrix CreditAttribution: joep.hendrix commentedThere was an error when pathing the file.
The code itself works fine when manually applied.
Here is a new patch file with the same code but without the error.
Comment #10
mbutcher CreditAttribution: mbutcher commentedA minor variation of JoepH's patch has been committed, and will be available in 6.x-2.1. Thanks hongbo and JoepH!
Comment #12
lemuelsantos CreditAttribution: lemuelsantos commentedPlease add this patch to Drupal 5 version;
No codes changes required I'm using the patch for Drupal 6 and it's working fine;
Thanks...
Comment #13
lemuelsantos CreditAttribution: lemuelsantos commentedwell... it needs to do a drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH) to get the function drupal_get_path_alias declared otherwise you are going to face a undefined function call;
Comment #14
Crell CreditAttribution: Crell commentedThe 5.x release is in maintenance mode only and is not taking new features.