Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from Dec 14, 2013
Merged

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

merged 4 commits into from Dec 14, 2013

Conversation

@kennydee
Copy link
Contributor

@kennydee 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


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
Copy link
Owner

@macbre 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 ++)

@ghost ghost assigned macbre Dec 13, 2013
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
Copy link
Owner

@macbre macbre commented Dec 14, 2013

Way better :) Thanks, @kennydee!

macbre added a commit that referenced this pull request Dec 14, 2013
Add "X-cache: PASS" support in cacheHits module
@macbre macbre merged commit 76adcdd into macbre:master Dec 14, 2013
1 check passed
1 check passed
default The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants