# Janitor flush specific page

**URL:** https://forum.getkirby.com/t/janitor-flush-specific-page/32359
**Category:** Plugins
**Tags:** v3
**Created:** [August 30, 2024, 5:22pm UTC](https://forum.getkirby.com/t/janitor-flush-specific-page/32359 "2024-08-30T17:22:30Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![timotheegoguely](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/timotheegoguely/32/13657_2.png) [@timotheegoguely](https://forum.getkirby.com/u/timotheegoguely)
#### Post date: [August 30, 2024, 5:22pm UTC](https://forum.getkirby.com/t/janitor-flush-specific-page/32359/1 "2024-08-30T17:22:30Z")

</div>

Hi @bnomei,

I would like to delete only one specific page (the `home` for example) using your [`janitor:flush`](https://github.com/bnomei/kirby3-janitor/blob/master/commands/flush.php) built it command, but I don’t get what should I pass to the `--name` parameter to do so.

I tried the following command, but it doesn’t work:

```php
janitor()->command('janitor:flush --name home --quiet');

```

I’m not sure it makes any difference, but I’m using [staticache](https://github.com/getkirby/staticache) plugin and it’s a multilingual K3 website, so the cache files I’m trying to delete are:

- `/pages/fr/index.html`
- `/pages/de/index.html`
- `/pages/en/index.html`

Thanks for your help 🙏

---

<div class="post-metadata">

### Author: ![bnomei](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/bnomei/32/775_2.png) [@bnomei](https://forum.getkirby.com/u/bnomei)
#### Post date: [August 30, 2024, 5:43pm UTC](https://forum.getkirby.com/t/janitor-flush-specific-page/32359/2 "2024-08-30T17:43:09Z")

</div>

neither kirby core not janitor support flushing a single page within the core pages cache. the name parameter should be set on the id of a cache like “pages” or “my.plugin”.

> **[Caching](https://getkirby.com/docs/guide/cache#plugin-caches)**
>
> Use Kirby's page cache or set up your own cache wherever you need it.

but you could create a custom command that removes the files you need given a page id. and then call that from janitor.

---

<div class="post-metadata">

### Author: ![bnomei](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/bnomei/32/775_2.png) [@bnomei](https://forum.getkirby.com/u/bnomei)
#### Post date: [August 30, 2024, 5:49pm UTC](https://forum.getkirby.com/t/janitor-flush-specific-page/32359/3 "2024-08-30T17:49:55Z")

</div>

on second thought… since the core pages cache (even if its powered by staticache plugin like in your case) adheres to the cache class interface your command could do something like this (untested).

`REMOVED`

and iterate over each language. i might find the time early next week to add that to janitor. I will report back then.

edited: removed the untested code example as it did not work as intended.

---

<div class="post-metadata">

### Author: ![bnomei](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/bnomei/32/775_2.png) [@bnomei](https://forum.getkirby.com/u/bnomei)
#### Post date: [September 1, 2024, 7:53am UTC](https://forum.getkirby.com/t/janitor-flush-specific-page/32359/4 "2024-09-01T07:53:44Z")

</div>

v4.4.0 adds the `trash` command which you can use in the CLI and as a panel button to remove entries of any cache by key. by default it will remove the pages cache for the current page.

```yml
  janitor_trash:
    type: janitor
    command: 'janitor:trash'
    label: Removes Pages Cache for this page
    icon: trash

```

> **[GitHub - bnomei/kirby3-janitor: Kirby Plugin for running commands like cleaning...](https://github.com/bnomei/kirby3-janitor)**
>
> Kirby Plugin for running commands like cleaning the cache from within the Panel, PHP code, CLI or a cronjob

---

<div class="post-metadata">

### Author: ![timotheegoguely](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/timotheegoguely/32/13657_2.png) [@timotheegoguely](https://forum.getkirby.com/u/timotheegoguely)
#### Post date: [September 1, 2024, 6:15pm UTC](https://forum.getkirby.com/t/janitor-flush-specific-page/32359/5 "2024-09-01T18:15:00Z")

</div>

Thank you very much for the new `trash` command! 🙏  
I tried to use it as follow, but it doesn’t work:

```php
janitor()->command('janitor:trash --key home --quiet')

```

Did you test it for multilang websites with staticache plugin?  
I am triggering it via the following webhook:

```php
'routes' => [ 
  [
      'pattern' => 'webhook/(:any)/(:any)',
      'action' => function($secret, $command) {
        if ($secret != janitor()->option('secret')) {
          \Kirby\Http\Header::status(401);
          die();
        }
        if ($command === 'janitor-trash-home') {
          janitor()->command('janitor:trash --key home --quiet');
        }
      }
    ]
]
```

---

<div class="post-metadata">

### Author: ![bnomei](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/bnomei/32/775_2.png) [@bnomei](https://forum.getkirby.com/u/bnomei)
#### Post date: [September 2, 2024, 5:21pm UTC](https://forum.getkirby.com/t/janitor-flush-specific-page/32359/6 "2024-09-02T17:21:15Z")

</div>

The pages cache creates a key for each language. Something like `home.en.html`. it will be the same key with or without the staticache plugin. But using the `--page` argument will be easier.

**web hook PHP**

```php
janitor()->command('janitor:trash --page home');

```

> since Janitor v4.3 the `--quiet` will automatically be appended if running commands in PHP and not the CLI

**CLI**  
`kirby janitor:trash --page home`

**some more examples on how to use the arguments directly in the command itself**

> <https://github.com/bnomei/kirby3-janitor/blob/92c16541ed5c16c6c84bfff930b9427d8eced9c0/commands/trash.php#L14>

---

<div class="post-metadata">

### Author: ![timotheegoguely](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/timotheegoguely/32/13657_2.png) [@timotheegoguely](https://forum.getkirby.com/u/timotheegoguely)
#### Post date: [September 3, 2024, 11:45am UTC](https://forum.getkirby.com/t/janitor-flush-specific-page/32359/7 "2024-09-03T11:45:18Z")

</div>

Thanks, it works perfectly now! 🎉

The examples you added as comments in the command itself are very useful!  
I even think you should add them directly to the [plugin README](https://github.com/bnomei/kirby3-janitor/blob/92c16541ed5c16c6c84bfff930b9427d8eced9c0/README.md), at least for those with arguments, to make them more accessible.
