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

Sitespeed.io is calculating CSS and Javascript size incorrectly #1963

Closed
abhagupta opened this issue Mar 27, 2018 · 15 comments
Closed

Sitespeed.io is calculating CSS and Javascript size incorrectly #1963

abhagupta opened this issue Mar 27, 2018 · 15 comments

Comments

@abhagupta
Copy link
Contributor

abhagupta commented Mar 27, 2018

Hi,

I have a HAR file which is capturing the CSS and JAVASCRIPTs incorrectly. I see the content size of these content types as 0 in the reports even though I see HAR file has CSS and Javascript files.

I am trying to trace down the code which calculates the CSS and Javascript size in PageXray but may be you can tell me more how this is calculated.

HAR file : https://github.com/abhagupta/sample_browsertime/blob/master/browsertime.json

@soulgalore
Copy link
Member

Hi @abhagupta thanks for reporting, hmm, looked at the HAR and the response is 304, so I think it could be that we in PageXray only look for 2XX responses when calculating the total size? Let men check that later on today.

Best
Peter

soulgalore added a commit to sitespeedio/pagexray that referenced this issue Mar 28, 2018
soulgalore added a commit to sitespeedio/pagexray that referenced this issue Mar 28, 2018
soulgalore added a commit that referenced this issue Mar 28, 2018
@soulgalore
Copy link
Member

@abhagupta I've pushed the change in master, hopefully making a release first thing tomorrow.

@abhagupta
Copy link
Contributor Author

Thanks so much for taking care of this so quickly. I will try it out today.

@abhagupta
Copy link
Contributor Author

@soulgalore On curious note, I am wondering how can we get a 304 anyways. 304 means browser recieved it from cache. But this should not have happened in sitespeed.io / selenium anyway.. am i missing something?

@soulgalore
Copy link
Member

@abhagupta hmm how are you running (I was thinking you where using a preScript or preURL)? Was it Chrome or FF? By default we use Selenium by creating a new profile etc but you can as extra functionality also add --cacheClearRaw (or --browsertime.cacheClearRaw), then instead of trusting Selenium, we use the Browsertime extension (the WebExtension) to fully clear the cache https://github.com/sitespeedio/browsertime-extension/blob/master/background.js#L146-L164 - I personally always use that last option when running in Docker, it probably be a thing we should add by default.

@abhagupta
Copy link
Contributor Author

Yes we are using a preScript. It does make sense now that it would get 304. I will use the --cacheClearRaw and try it. Thanks

@soulgalore
Copy link
Member

Ah sorry, I didn't explain it clear enough. The --cacheClearRaw happens before a run (before preScript/preURL). I've seen people in issues trying to disable the cache for Chrome to achieve not caching in pre steps but I haven't fully been able to understand the use case?

@soulgalore
Copy link
Member

Checkout sitespeedio/chrome-har#1

@abhagupta
Copy link
Contributor Author

Ah cool.. so its not just me. And it makes much more sense now. I tried to reproduce this on Chrome Dev tools and I saw a similar behavior what sitespeed was showing.. My preScript creates a cookie on the page and refreshes it. So I am definitely on the same page with same assets when its reloaded after cookie is inserted. When I open my app in chrome and check chrome dev tools, I see I get 304 responses for these CSS and Javascript files. (I made sure that I have Disable Cache unhecked, meaning I am letting Chrome to cache the assets). Selenium is doing exact behavior. If I do not clear the cache explicitly in my preScript after loading the cookie, browser is going to load it from cache. Thats what it is meant to do.

Btw. I used the --browsertime.cacheClearRaw and it worked. I do get a 200 response in the HAR file and also the metrics that I am expecting. So you might be ok NOT pushing the change you made.

Are you sure about The --cacheClearRaw happens before a run (before preScript/preURL) though?

I think otherwise because --browsertime.cacheClearRaw browsertime is going to clear the cache before it starts testing for performance which I am assuming starts after preScript is already executed. Correct me if I am wrong.

Thanks for all the help and information .

@abhagupta
Copy link
Contributor Author

abhagupta commented Mar 28, 2018

oops... i guess this option --browsertime.cacheClearRaw will remove my cookie
as well.

@abhagupta
Copy link
Contributor Author

abhagupta commented Mar 29, 2018

Yep, confirmed that cookie that I added in the preScript gets deleted becasue of --browsertime.cacheClearRaw. So may be we do need the pagexray change you made to capture content from 304 response. I will wait for the release. thanks again and sorry for spamming this issue .

@abhagupta
Copy link
Contributor Author

@soulgalore please let me know if the release to pagexray has been made.

@soulgalore
Copy link
Member

@abhagupta it is released but not sitespeed.io yet.

@soulgalore
Copy link
Member

@abhagupta released it just now, the container should be there in 5 min.

@soulgalore
Copy link
Member

Released some time ago, hope it works fine :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants