# Detecting Page Changes

**URL:** <https://www.ruby-forum.com/t/detecting-page-changes/116906>\
**Category:** Radiant CMS\
**Created:** [October 11, 2007, 12:21am UTC](https://www.ruby-forum.com/t/detecting-page-changes/116906 "2007-10-11T00:21:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahadewa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9e8a1a/32.png) [@mahadewa](https://www.ruby-forum.com/u/mahadewa)\
**Post date:** [October 11, 2007, 12:21am UTC](https://www.ruby-forum.com/t/detecting-page-changes/116906/1 "2007-10-11T00:21:11Z")

</div>

I’m trying to figure out a way to track whenever a given page’s rendered  
output may have changed.

Kind of tricky since changing the layout or, worse yet, a snippet could  
change the page’s output. And then, of course, there are those silly  
extensions people keep making 😃 with all their dynamic tags.

Does anyone have any clever suggestions to deduce that the page’s output  
may  
be changed? I’d love to have an event (or set of events) to trigger the  
check but would settle for a smart polling solution (but it should scale  
well).

## BTW, I’d love to be able to “know” that the page had changed but, for my purposes, even being able to suspect it’s guilt would be sufficient.

View this message in context:  
[http://www.nabble.com/Detecting-Page-Changes-tf4603945.html#a13145924](http://www.nabble.com/Detecting-Page-Changes-tf4603945.html#a13145924)  
Sent from the Radiant - User mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![mahadewa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9e8a1a/32.png) [@mahadewa](https://www.ruby-forum.com/u/mahadewa)\
**Post date:** [October 11, 2007, 1:44am UTC](https://www.ruby-forum.com/t/detecting-page-changes/116906/2 "2007-10-11T01:44:22Z")

</div>

> I’m trying to figure out a way to track whenever a given  
> page’s rendered  
> output may have changed.

I was doing some thinking about this recently, but haven’t had a go at  
implementing yet.

My basic idea was:

Add a listener that hooks into after\_initialize on page, snippet and  
layout.

Hook into SiteController - reset the listener before rendering the page,  
and then read out the list of accessed objects after the  
render is complete and dump that list to the db.

Have a listener that hooks into after\_save on page, snippet and layout.  
Read the list of urls that accessed that object and clear  
them all - for pages also clear anything that has accessed the parent  
page.

This should give pretty much complete coverage for pages with content  
that depend only on db changes. Any content that is time  
sensitive though, you’ll have to have some other mechanism for.

Dan.

---

<div class="post-metadata">

**Author:** ![mahadewa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9e8a1a/32.png) [@mahadewa](https://www.ruby-forum.com/u/mahadewa)\
**Post date:** [October 12, 2007, 2:03pm UTC](https://www.ruby-forum.com/t/detecting-page-changes/116906/3 "2007-10-12T14:03:37Z")

</div>

> I’m trying to figure out a way to track whenever a given page’s  
> rendered output may have changed.

Just curious, what functionality do you want to achieve with this?

```
/AITOR
```

---

<div class="post-metadata">

**Author:** ![mahadewa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9e8a1a/32.png) [@mahadewa](https://www.ruby-forum.com/u/mahadewa)\
**Post date:** [October 15, 2007, 6:04pm UTC](https://www.ruby-forum.com/t/detecting-page-changes/116906/4 "2007-10-15T18:04:25Z")

</div>

I wish there was a per page cache time property. That way dynamic  
pages had shorter cache times. Perhaps tags on page would adjust the  
cache time setting for the page.

That way proper cache expiration times could be reported back to the  
browser and components like yours could get an idea of how dynamic the  
page content is.

On 10/14/07, Chris P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> validation (passed, failed, unknown, etc). That way I could present a  
> Radiant mailing list  
> Post: removed\_email\_address@domain.invalid  
> Search: [http://radiantcms.org/mailing-list/search/](http://radiantcms.org/mailing-list/search/)  
> Site: [http://lists.radiantcms.org/mailman/listinfo/radiant](http://lists.radiantcms.org/mailman/listinfo/radiant)

–  
Regards,  
Hiram

Blog: [http://hiramchirino.com](http://hiramchirino.com)

---

<div class="post-metadata">

**Author:** ![mahadewa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9e8a1a/32.png) [@mahadewa](https://www.ruby-forum.com/u/mahadewa)\
**Post date:** [October 18, 2007, 10:22am UTC](https://www.ruby-forum.com/t/detecting-page-changes/116906/5 "2007-10-18T10:22:26Z")

</div>

> I wish there was a per page cache time property. That way dynamic  
> pages had shorter cache times. Perhaps tags on page would adjust the  
> cache time setting for the page.

Just set response.cache\_timeout (to a value in seconds) from your  
page model.

Dan.

---

<div class="post-metadata">

**Author:** ![mahadewa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9e8a1a/32.png) [@mahadewa](https://www.ruby-forum.com/u/mahadewa)\
**Post date:** [October 14, 2007, 11:10pm UTC](https://www.ruby-forum.com/t/detecting-page-changes/116906/6 "2007-10-14T23:10:31Z")

</div>

Aitor Garay-Romero wrote:

> > I’m trying to figure out a way to track whenever a given page’s  
> > rendered output may have changed.
> 
> Just curious, what functionality do you want to achieve with this?  
> I am building a validator extension - I’ll announce v0.1 here shortly.  
> Initially, it will retain no memory of the tests - you just run it on a  
> page to validate the markup and get handed the result.

In future versions, however, I’d like to store the results of the  
validation (passed, failed, unknown, etc). That way I could present a  
report/view to the users showing which pages been validated (and their  
results) and which haven’t.

As you’ve probably guessed, if I want to store whether the page is  
valid, I need to know if a page has changed so that I can change its  
status as ‘unknown’.

-Chris

---

<div class="post-metadata">

**Author:** ![mahadewa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9e8a1a/32.png) [@mahadewa](https://www.ruby-forum.com/u/mahadewa)\
**Post date:** [October 18, 2007, 10:24am UTC](https://www.ruby-forum.com/t/detecting-page-changes/116906/7 "2007-10-18T10:24:12Z")

</div>

> I wish there was a per page cache time property. That way dynamic  
> pages had shorter cache times. Perhaps tags on page would adjust the  
> cache time setting for the page.

Just set response.cache\_timeout (to a value in seconds) from your  
page model.

Dan.
