# \[Try it\] A Script to Clear web-proxy cache

**URL:** <https://forum.mikrotik.com/t/try-it-a-script-to-clear-web-proxy-cache/31120>\
**Category:** Scripting\
**Created:** [September 2, 2009, 11:24pm UTC](https://forum.mikrotik.com/t/try-it-a-script-to-clear-web-proxy-cache/31120 "2009-09-02T23:24:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![maaking2](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/maaking2/32/353_2.png) [@maaking2](https://forum.mikrotik.com/u/maaking2)\
**Post date:** [September 2, 2009, 11:24pm UTC](https://forum.mikrotik.com/t/try-it-a-script-to-clear-web-proxy-cache/31120/1 "2009-09-02T23:24:56Z")

</div>

Hello,

For everyone who want to clear proxy cache, try the follwing scripts.  
  
  
1- add thescript

if you have ver 3.x then use: (tested and works!)

```plaintext
/system script add name=script_clear_cache source="/ip proxy clear-cache"

```

if you have ver 2.x (not tested)

```plaintext
/system script add name="script_clear_cache " source={
/ip firewall nat disable [find action=redirect]
/ip web-proxy set enabled=no
/ip web-proxy clear-cache
/ip web-proxy set enabled=yes
/ip firewall nat enable [find action=redirect]
}

```

2-scheduler  
now we come to the scheduler: which will run the script (script\_clear\_cache)

```plaintext
/system scheduler
add comment="" disabled=no interval=1d name=clear_proxy_cache on-event=script_clear_cache start-date=Jan/01/1970 start-time=00:00:00

```

Note her: interval=1d

this is the interval for the script to run, i use it everyday. if you want it weekly just use: interval=7d for monthly user: interval=30d

The start date: start-date=Jan/01/1970 is the date when the script to start. you can use future date like: sep/30/2009 etc..

good luck everybody

---

<div class="post-metadata">

**Author:** ![Chupaka](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/chupaka/32/215_2.png) [@Chupaka](https://forum.mikrotik.com/u/Chupaka)\
**Post date:** [September 3, 2009, 2:16pm UTC](https://forum.mikrotik.com/t/try-it-a-script-to-clear-web-proxy-cache/31120/2 "2009-09-03T14:16:11Z")

</div>

just interesting: why do you need that?..

---

<div class="post-metadata">

**Author:** ![fewi](https://forum.mikrotik.com/letter_avatar/fewi/32/6_449c533f586939b6e5f246632a46421f.png) [@fewi](https://forum.mikrotik.com/u/fewi)\
**Post date:** [September 3, 2009, 3:25pm UTC](https://forum.mikrotik.com/t/try-it-a-script-to-clear-web-proxy-cache/31120/3 "2009-09-03T15:25:56Z")

</div>

Maybe I’m missing something here, but couldn’t you just set

> max-fresh-time (time; default: 3d) - an upper limit on how long objects without an explicit expiry  
> time will be considered fresh

to 1 day and have objects expire from the cache dynamically without needing a script?

---

<div class="post-metadata">

**Author:** ![chapex](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/chapex/32/349_2.png) [@chapex](https://forum.mikrotik.com/u/chapex)\
**Post date:** [September 5, 2009, 4:44pm UTC](https://forum.mikrotik.com/t/try-it-a-script-to-clear-web-proxy-cache/31120/4 "2009-09-05T16:44:17Z")

</div>

It would be good that the clean does after coming to a certain volume. In case of the SD it would take better of the useful life. (memory celds)

regards

---

<div class="post-metadata">

**Author:** ![Chupaka](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/chupaka/32/215_2.png) [@Chupaka](https://forum.mikrotik.com/u/Chupaka)\
**Post date:** [September 5, 2009, 5:42pm UTC](https://forum.mikrotik.com/t/try-it-a-script-to-clear-web-proxy-cache/31120/5 "2009-09-05T17:42:07Z")

</div>

better?.. why?..

---

<div class="post-metadata">

**Author:** ![chapex](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/chapex/32/349_2.png) [@chapex](https://forum.mikrotik.com/u/chapex)\
**Post date:** [September 5, 2009, 5:54pm UTC](https://forum.mikrotik.com/t/try-it-a-script-to-clear-web-proxy-cache/31120/6 "2009-09-05T17:54:24Z")

</div>

> [@Chupaka](#):
>
> better?.. why?..

vanilla kernel does not good management on memories of limited use. It’s not performed fot that. That’s why after reaching the top of capacity, there was a drain, not to be writing constantly on the same cells.

regards

---

<div class="post-metadata">

**Author:** ![karina](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/karina/32/719_2.png) [@karina](https://forum.mikrotik.com/u/karina)\
**Post date:** [April 26, 2013, 8:51am UTC](https://forum.mikrotik.com/t/try-it-a-script-to-clear-web-proxy-cache/31120/7 "2013-04-26T08:51:15Z")

</div>

I think Script is required as the dynamic expiry seems to fail. My webproxy is set to 3d max fresh however when I look in proxy contents there are many objects over 7 days old and more, or am I missing something
