Hi,

First thank you for your module.

I have added some features to your module for my own needs :

- Boost expire have a block to clear the cache
- Boost expire can clear all the cache or just the current page (not working for url likes node?page=1 but ok for all nodes)
- On Insert/Update node or Insert/Update comment, Boost expire just clear the current node, not all the cache
- The watchdog message is configurable on the Boost debug configuration page : admin/config/system/boost/debug
- A permission is now needed to use Boost expire module

Feel free to reuse/change anything you wish :-)

See : http://drupal.org/node/1401440#comment-5456316 for the module ...

Comments

Marvine’s picture

StatusFileSize
new8.83 KB

Here is the module !

geerlingguy’s picture

Title: Here are some new features » Allow per-page boost cache flushing

I'd definitely like to add in something for clearing out a particular page's cache entry, so I'm updating the title to reflect this. You have a good start—I would recommend you run the code through Coder Review so you can ensure you're conforming to Drupal coding standards (and it helps me to be able to bring in code a little quicker :).

Marvine’s picture

StatusFileSize
new8.83 KB

Indeed !

It should be better now.

p4trizio’s picture

Hi Marvine, great job.
I would suggest to retrieve the home page path with variable_get() like this

<?php
function boost_expire_flush_boost_page($base_dir, $page) {
  // @TODO : $page doesn't work with url like node?page=1
  // Front page
  $result = 0;
  var_dump($page);
  $front_page=variable_get('site_frontpage', 'node');
  if ($page == $front_page) {
    $file_to_del = $base_dir . '_.html';
  }
?>

And I would also suggest to set some variables where the administrator can choose if to enable expiring home page on certain events (node updates, comments, etc) since the home page might cange considering blocks, views and other stuff

Thank you again!

EDIT:
would be nice also to use drupal_get_path_alias($path) to flush pages with aliases and not just node/x
Hope it was helpful!

Jake081’s picture

Hello,

are there any news about only flushing single nodes from boost cache. Will boost expire officially (without external patches) have this function in the future or are there other ways to get that boost-6 functionality back?

As I have about 150.000 nodes and frequent changes, always deleting the whole boost-cache makes not much sense...

geerlingguy’s picture

I'm definitely considering adding something like this patch in soon, but haven't had time to work on evaluating the patch/making sure it runs well for everyone. I definitely want to keep this module (as a whole) very simple, especially since (someday) the Cache Expire module is supposed to offer much better/deeper integration with Boost for Drupal 7. In a way, this module is supposed to be more of a stopgap for many site owners, like me, who hate simply having to delete their entire cache manually all the time :)

If you have time to test, make an official patch, and review the patch, that would be most helpful, as this module is a little lower on my priority list right now. (Issue is still 'active' because there's no actual patch to test).

geerlingguy’s picture

For those following this issue, I've at least set the module to be configurable to respect your site's 'Minimum cache lifetime' option (on the new Boost Expire settings page), so your cache, in that case, wouldn't be cleared until the minimum lifetime has passed. See: #1405656: Respect "Minimum cache lifetime" option.

Also, if someone could roll the attached module into a patch, that would help me greatly in reviewing the changes and structure... (plus we could set this issue to 'needs review' instead of 'active' :-).

alandor’s picture

I'm using the Boost Expire module for a site I'm working on. I would appreciate very much if it were possible just to flush the current page rather than the whole cache. I can't get Marvine's solution to work properly though, the "Clear all Boost module cache" link works but not "Clear Boost module cache for this page".

I have no experience of making modules or patches so I can't do much to help you with this. But I can help out testing it when you've come that far.

EDIT: I just realized that the reason it doesn't work is because I'm using URL aliases. The "Clear Boost module cache for this page" clears the cache for the actual node, but it doesn't affect the URL alias which still has its old html-file to refer to.

sijuwi’s picture

Is this true that it doesn't work with url alias'? Any more work planned on this module?

gocaps’s picture

Marvine's version of the module is working great for me, and it's working with URL aliases.

giorgio79’s picture

Status: Active » Reviewed & tested by the community

As per #10

geerlingguy’s picture

Status: Reviewed & tested by the community » Needs work

If someone can roll the module changes into a patch, that makes it a lot easier for me to review and accept.

Je K Ryan’s picture

Version: 7.x-1.0 » 7.x-1.1
Status: Needs work » Needs review
StatusFileSize
new5.96 KB

Just converted Marvine's tarball from #3 into a patch as per Jeff's request in #12.

Please note:
1) This is my first attempt at creating a patch (just downloaded Git and following documentation) so please let me know of any problems.

2) I am a newbie at php, thus unable to review the code, just created the patch to help out.

Hope it works
JK

geerlingguy’s picture

@Je Kyran - thanks for doing that! Even though you say you're a newbie and this is your first time using Git, it looks like you've done everything quite well. And always feel free to pop into the #drupal-contribute IRC channel for help.

A couple quick notes on the patch:

193 +  var_dump($page);

Extra var_dump() in there... needs to be removed.

Also, a few things here and there have improper formatting (comments and spacing, mostly); please consider running the module through Coder Review before creating the final patch, just to make sure everything's up to snuff :)

I may try to take some time and review this soon; it looks like work on #1126122: Boost ability to invalidate/clear cache for single items based on event handler hooks like hook_node_update() hasn't progressed in quite a while.

Je K Ryan’s picture

Sorry for delay.

I have cleaned the code as per the results of Code Review and Coder Tough Love.

I have changed unlink() in line 211 to domxml_unlink_node() as per the following instruction from Code Review
- unlink() is a function name alias, use domxml_unlink_node() instead [sniffer_semantics_functioncall_functionalias]

JK

geerlingguy’s picture

I've added in a few more fixes, tweaked a couple additional code style errors (no doubt adding a few of my own ;), and made a patch that applies to the current -dev release.

I like what I'm seeing so far, but there are a couple quirks:

  1. I'd like to just use boost_expire_flush_boost_cache() as both a utility function and the page callback, so maybe one solution would be to forego the '$options' array and just have '$path' be the parameter. If empty, assume that the entire cache should be clear. Because, as-is, if someone has a page named 'all' on the site, it would clear all caches. Plus, it just seems klunky to have an additional page callback boost_expire_clear_cache().
  2. On hook_node_insert(), hook_node_update(), etc., remember that a node save, comment save, etc. might also need to clear out caches of views, the front page, etc., and not just the single node's 'view' page. Therefore, I might want to add a setting that lets admins choose the current behavior (flush all caches when a node is added or updated), or the new behavior (flush only the node's cache), and default to the current behavior (since that's what people expect right now).
  3. boost_expire_flush_boost_page() needs to be more robust; right now it's a bit fragile in that it doesn't handle query parameters or certain cases appropriately. I also fixed the special handling for the front page (it could be something other than 'node') in this patch.
Je K Ryan’s picture

@geerlingguy
I just realised that the patch I attached to #15 was incorrectely created. I had mistakenly committed some changes while messing around with the Git GUI and as a result the patch is based on comparing with an interim code base rather than the master.

I doubt that a corrected version is of much use now that you've already move the code forward, but I am attaching it anyway just for the formality I guess, but in the hope that it might help in some way.

So this patch is simply what #15 should have been and does not include changes of #16.

Apologies for the mixup on my part.
JK

marcoka’s picture

this is a great module as boost is missing this "management". i am testing #16
#16, seems a ) is missing

Index: sites/all/modules/contrib/boost_expire/boost_expire.module
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- sites/all/modules/contrib/boost_expire/boost_expire.module (revision )
+++ sites/all/modules/contrib/boost_expire/boost_expire.module (revision )
@@ -113,7 +113,7 @@
*/
function boost_expire_clear_cache($arg = NULL) {
// If no argument, flush the entire Boost cache.
- if (empty($arg) {
+ if (empty($arg)) {
$result = boost_expire_flush_boost_cache(array('scope' => 'all'));
drupal_set_message(t('Boost cache cleared.'));
}

Clearch cache for page
#1448476: Admin status block in 7.x-1.x
The "Clear Boost cache for this page" does not work on the frontpage, but the core boost block flush cache works:
http://www.root.artwaves.de/screensnapr/1360925639-pI87Bn.jpg
i use the latest boost dev it has this integrated

function boost_block_flush_form() {
  $form = array();

  $form['boost_cache']['clear'] = array(
    '#type' => 'submit',
    '#value' => t('Flush Page'),
  );

  return $form;
}

function boost_block_flush_form_submit() {
  $_boost = boost_transform_url();

  // We need the extention for the filename
  $_boost['header_info'] = boost_get_header_info();
  $_boost['matched_header_info'] = boost_match_header_attributes($_boost['header_info']);

  $filename = $_boost['filename'] . '.' . $_boost['matched_header_info']['extension'];

  if (is_file($filename)) {
    if (unlink($filename)) {
      drupal_set_message(t('%filename was deleted from the Boost cache', array('%filename' => $filename)));
    }
    else {
      drupal_set_message(t('%filename could not be deleted, check file permissions on disk to see if the web server can write/delete the file.', array('%filename' => $filename)));
    }
  }
  else {
    drupal_set_message(t('%filename was not found in the Boost cache and could not be deleted.', array('%filename' => $filename)));
  }

Pathauto

The module will not work if pathauto is used because it uses the normal iternal iurl
$file_to_del = cache/normal/dev.test.net/node/207_.html

dianikol’s picture

Category: task » bug
Priority: Normal » Major
StatusFileSize
new538 bytes

I made a small change @16 patch in order to work with pathauto so it can delete the cached page using path alias

This patch MUST BE APPLIED AFTER @16 PATCH

geerlingguy’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
Status: Needs review » Closed (won't fix)

Thank you to all for your hard work in this issue—now that Cache Expiration works with Boost in Drupal 7, the Boost Expire module is being deprecated; and, happily, Cache Expiration already has the functionality this issue was trying to provide! More info: #2029269: Deprecate Boost Expire in favor of Cache Expiration.

geerlingguy’s picture

Issue summary: View changes

File attachment in second post