Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8374363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:54:22+00:00 2026-06-09T14:54:22+00:00

I am using WWW::Mechanize::Cached together with Cache::FileCache, and I’d like to remove certain URLs

  • 0

I am using WWW::Mechanize::Cached together with Cache::FileCache, and I’d like to remove certain URLs from the cache sometimes but WWW::Mechanize::Cached doesn’t have such an option.

I’ve looked through the source code, and can see that the caching is set using this line:

$self->cache->set( $req, freeze( $response ) ) if $should_cache;

So I’ve tried using the following code to remove an item from the cache:

$cache->remove($mech->response->request) or warn "cannot remove $!";

or

$cache->remove($mech->response->request->as_string) or warn "cannot remove $!";

But I get the warning: “cannot remove No such file or directory”.

I’ve also found the following ideas, but none seem to work
https://groups.google.com/forum/?fromgroups#!topic/perl-cache-discuss/M_wXFNL5MdM%5B1-25%5D

if ( $want_to_delete_url ) {
    $mech->cache->remove( $url );
}
$mech->get( $url );

http://www.perlmonks.org/?node_id=564208

my $url = "http://www.rulez.sk/headers.php";
my $req = GET $url, 'Accept-Encoding' => 'identity';
$cache->remove($req->as_string) or print "cannot remove $!";
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T14:54:23+00:00Added an answer on June 9, 2026 at 2:54 pm

    It helps to read the documentation of the software you’re working with. CHI lists all cache keys with the get_keys method, so you can simply iterate over them until you find the one you want.

    use 5.010;
    use CHI qw();
    use HTTP::Request qw();
    use WWW::Mechanize::Cached qw();
    
    my $cache = CHI->new(
        driver     => 'CacheCache',
        cc_class   => 'Cache::FileCache',
        cc_options => { cache_root => '/tmp' },
    );
    my $uri = 'http://www.iana.org/domains/example/';
    my $mech = WWW::Mechanize::Cached->new(cache => $cache);
    $mech->get($uri);
    for my $key ($cache->get_keys) {
        my $r = HTTP::Request->parse($key);
        say $r->uri;
        $cache->remove($key) if $r->uri eq $uri;
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to search content from a site using WWW::Mechanize but to be able
I'm using WWW::Mechanize to do some standard website traversal, but at one point I
I'm trying to use WWW::Mechanize to extract some links from the HTML page using
I'm using WWW::Mechanize to retrieve a form from a webpage: #!/usr/bin/perl use WWW::Mechanize; my
I am using WWW::Mechanize to crawl sites, and it works great except for sometimes
I'm trying to login automatically in a website using Perl with WWW::Mechanize . What
Im using mechanize to parse http://www.hammacher.com/Category/Default.aspx?uq=Gifts-Under-30&all=True What xpath can I use to get to
tI am using rally developer (www.rallydev.com) and would like to use a date picker
I'm using mechanize in windows 7 x64 OS, but got the the uninitialized constant
Using Mechanize with Ruby I get a certain file using agent.get('http://example.com/foo.torrent') , with FileUtils

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.