Add "X-cache: PASS" support in cacheHits module #166

Merged
merged 4 commits into from Dec 14, 2013

Conversation

Projects
None yet
2 participants
@kennydee
Contributor

kennydee commented Dec 13, 2013

Hi,

I don't know if this PR could have some interest for you, but in case ...

This PR add X-cache PASS metrics.

In our Varnish, we have HIT, MISS and PASS.

PASS tell us there is a rule which exclude cache on this request, and tell us which rules.

And PASS request, is a thing that we have to look, because it means that every hit go to the backend !

;) Thanks

@macbre

View changes

modules/cacheHits/cacheHits.js
- var re = /miss|hit/i;
+ var re = /miss|hit|pass/i;
// examples:
// X-Cache:HIT, HIT
// X-Cache:arsenic miss (0)
phantomas.on('recv', function(entry,res) {
var header = entry.headers['X-Cache'] || '',

This comment has been minimized.

@macbre

macbre Dec 13, 2013

Owner

As toLowerCase() is now called twice on header I'd move the call here.

@macbre

macbre Dec 13, 2013

Owner

As toLowerCase() is now called twice on header I'd move the call here.

@macbre

This comment has been minimized.

Show comment
Hide comment
@macbre

macbre Dec 13, 2013

Owner

Makes perfect sense to me :)

Please run JS Lint against your changes by npm run-script lint - it reports mixed tabs and spaces.

Owner

macbre commented Dec 13, 2013

Makes perfect sense to me :)

Please run JS Lint against your changes by npm run-script lint - it reports mixed tabs and spaces.

@@ -155,6 +155,7 @@ phantomas metrics for <https://github.com/macbre/phantomas>:
* otherSize: 0
* cacheHits: 9
* cacheMisses: 0
+* cachePasses: 0

This comment has been minimized.

@macbre

macbre Dec 13, 2013

Owner

Please update information about number of metrics above (it got ++)

@macbre

macbre Dec 13, 2013

Owner

Please update information about number of metrics above (it got ++)

@ghost ghost assigned macbre Dec 13, 2013

@macbre

View changes

modules/cacheHits/cacheHits.js
+ isPass = header.toLowerCase().indexOf('pass') > -1;
+ if (isPass) {
+ phantomas.incrMetric('cachePasses');
+ phantomas.log('Cache pass: on <' + entry.url + '> (X-Cache: ' + header + ')');

This comment has been minimized.

@macbre

macbre Dec 13, 2013

Owner

You may want to use offenders (see #140) for reporting requests being passed to the backend. Simply call phantomas.addOffender('cachePasses', entry.url);

@macbre

macbre Dec 13, 2013

Owner

You may want to use offenders (see #140) for reporting requests being passed to the backend. Simply call phantomas.addOffender('cachePasses', entry.url);

@macbre

This comment has been minimized.

Show comment
Hide comment
@macbre

macbre Dec 14, 2013

Owner

Way better :) Thanks, @kennydee!

Owner

macbre commented Dec 14, 2013

Way better :) Thanks, @kennydee!

macbre added a commit that referenced this pull request Dec 14, 2013

Merge pull request #166 from kennydee/master
Add "X-cache: PASS" support in cacheHits module

@macbre macbre merged commit 76adcdd into macbre:master Dec 14, 2013

1 check passed

default The Travis CI build passed
Details

@kennydee kennydee referenced this pull request in M6Web/m6web.github.io Dec 14, 2013

Merged

add macbre/phantomas oss contribution #17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment