httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Karim Zaki <Karim.Z...@itworx.com>
Subject RE: [users@httpd] Clearing cache selectively on Apache + mod_cache
Date Tue, 02 Dec 2008 10:15:23 GMT
That's not great news. When you say the hostname, do you mean ServerName or the address configured
for the virtual host? I don't have any problems setting the same ServerName for both.

-----Original Message-----
From: André Warnier [mailto:aw@ice-sa.com]
Sent: Monday, December 01, 2008 6:10 PM
To: users@httpd.apache.org
Subject: Re: [users@httpd] Clearing cache selectively on Apache + mod_cache

One last note : following your original post, I re-read the Apache
documentation on "caching content" (never a bad idea, that).
In there, I saw something about the fact that in order to cache content,
mod_cache calculates a hashcode for the URL to cache, in which
calculation is included (and that is the important part) the *hostname*
(for example the name of your VirtualHost).
Which leads me to believe that, as such, the scheme proposed with the
separate VirtualHost will not work as simply as expected.
There is also somewhere in there the indication that you can overcome
this by using another directive, but I have no idea if that would have
or not other undesirable consequences in your case.


Karim Zaki wrote:
> I think I will try using the virtual host option first..
>
> Thanks to everyone for your contributions to the discussion.
>
> -----Original Message-----
> From: André Warnier [mailto:aw@ice-sa.com]
> Sent: Monday, December 01, 2008 3:54 PM
> To: users@httpd.apache.org
> Subject: Re: [users@httpd] Clearing cache selectively on Apache + mod_cache
>
> 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@ice-sa.com]
>> Sent: Monday, December 01, 2008 2:50 PM
>> To: users@httpd.apache.org
>> Subject: Re: [users@httpd] 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@ice-sa.com]
>>> Sent: Monday, December 01, 2008 1:36 PM
>>> To: users@httpd.apache.org
>>> Subject: Re: [users@httpd] 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@ice-sa.com]
>>>> Sent: Monday, December 01, 2008 1:00 PM
>>>> To: users@httpd.apache.org
>>>> Subject: Re: [users@httpd] 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@httpd.apache.org
>>>>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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@httpd.apache.org
>>>>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> 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@httpd.apache.org
>>>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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@httpd.apache.org
>>>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> 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@httpd.apache.org
>>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> 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@httpd.apache.org
>>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> 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@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
> ---------------------------------------------------------------------
> 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@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>


---------------------------------------------------------------------
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@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


---------------------------------------------------------------------
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@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message