Re: Clearing cache selectively on Apache + mod_cache

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When I look at this series of messages, and at a previous thread on this list, with subject : Best filesystem type for mod_cache in reverse proxy?
and at this :
http://httpd.apache.org/docs/2.2/caching.html
then I get the idea that the directory/file structure used by mod_disk_cache is not so complex. It might thus be possible to write a simple script which, based on the URL of the page that has changed in Tomcat, just goes into that file structure and deletes that document.
After all, this seems to be the way in which htcacheclean is doing it.
What I do not know is if between htcacheclean and mod_cache, there is any synchronisation happening.

Alternatively, if your Apache server already has mod_perl loaded, there are probably a couple of ways that this can be done with a mod_perl module. But you probably would not want to load mod_perl just for that.

Karim Zaki wrote:
Yes. When a page changes, this fires an event, which I can catch and run some code. I would like that code to clear the cache for this specific page.

-----Original Message-----
From: André Warnier [mailto:aw@xxxxxxxxxx]
Sent: Monday, December 01, 2008 2:50 PM
To: users@xxxxxxxxxxxxxxxx
Subject: Re:  Clearing cache selectively on Apache + mod_cache

Ok then.
So, how do you know that a given page changed ?
I mean, if you don't want to wait, it means you have some way to know
that the page has changed for which you don't want to wait, right ?


Karim Zaki wrote:
This is exactly what is in place right now. I've written a filter in Tomcat to set the "Expires" header, and Apache honors it. However, when a page changes, I don't want to have to wait 24 hours for that change to reflect in the cache, and I don't want to have to clear the whole cache either. I want to selectively "push" the change to the cache by clearing that specific page from the apache cache so that the next time it is requested, it will be regenerated with the new content and cached.

-----Original Message-----
From: André Warnier [mailto:aw@xxxxxxxxxx]
Sent: Monday, December 01, 2008 1:36 PM
To: users@xxxxxxxxxxxxxxxx
Subject: Re:  Clearing cache selectively on Apache + mod_cache

I guess it all depends on your definition of "dynamic", and how you
handle this at the source.

When your Tomcat generates an answer page, it can add HTTP headers that
indicate for how long this content is valid.  If it doesn't, then by
default this means that the page is effectively "dynamic" (meaning that
each request could theoretically return a different answer next time).
What I mean by this, is that if your Tomcat added the right "Expires"
header in the first place (saying 24 hours), then you would have what
you seem to want, without having to do anything special in addition.
I would expect mod_cache at the Apache level, to take this information
into account, and serve the local copy instead of asking Tomcat again,
at least during these 24 hours. Then, when mod_cache realises that the
page's "valid until" date has passed, it will request a new version from
Tomcat automatically.

So, is there any particular reason why the above scheme is not
applicable in your case ?


Karim Zaki wrote:
But that would be like re-implementing mod_cache, wouldn't it? Apache is already doing this for me. It's caching the dynamic content, keeping it for 24 hours, and checking if it's in cache before requesting it from the back-end server. The only problem is that I need to sometimes clear certain pages from cache.

-----Original Message-----
From: André Warnier [mailto:aw@xxxxxxxxxx]
Sent: Monday, December 01, 2008 1:00 PM
To: users@xxxxxxxxxxxxxxxx
Subject: Re:  Clearing cache selectively on Apache + mod_cache

Karim Zaki wrote:
Greetings all,

I'm running Apache/2.2.10 (Win32) mod_jk/1.2.27 + mod_cache. I'm looking for a way to clear the cache from Apache for specific URLs. I'm using Apache to cache dynamic content that is served by Tomcat, and I would like to keep the content (age) high (e.g. 24 hours) but still to be able to clear the cache for specific pages when the content is updated. Is there a way to tell Apache to clear the cache for a specific list of URLs?

Hi.
I am not going to answer your original question, but I just have a
couple of remarks based on your description above, and maybe a different
way of thinking about this.

You say that you want to cache dynamic content generated by Tomcat, for
24 hours.
In other words, it is not really dynamic content, because for 24 hours
your users are going to get the same unique version.

If so, then why would you not generate these pages in advance, and put
them somewhere on your Apache server to be served as static content ?
Then each 24 hours you can do the same and refresh them from Tomcat.
(This would be fairly simple to do using a script, calling something
like wget or curl, or in perl using LWP).

I believe it is fairly simple to configure your Apache in such a way
that it will look first of this URL is available as a static page, and
if not forward the call to Tomcat.
(using mod_rewrite e.g.).


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx




---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx




---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux