pagespeed insights

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

pagespeed insights

Post by Vegan »

Google Pagespeed Insights seems to have to suggestions I might be able to fix but I am not if it can be done without breaking my sites

Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network.

How can I deal with mobile v desktop and the way facebook is good for 20 minutes and facebook is good for 2 hours

I was wondering how to get the caching working better, considering my site is database driven


https://hardcoregames.azurewebsites.net ... s/logo.png (expiration not specified)
https://hardcoregames.azurewebsites.net ... ebfont.ttf (expiration not specified)
https://hardcoregames.azurewebsites.net ... mbnail.png (expiration not specified)
https://hardcoregames.azurewebsites.net ... loader.gif (expiration not specified)
https://hardcoregames.azurewebsites.net ... atured.png (expiration not specified)
https://hardcoregames.azurewebsites.net ... latest.png (expiration not specified)
https://hardcoregames.azurewebsites.net ... search.png (expiration not specified)
https://connect.facebook.net/en_US/all.js (20 minutes)
https://www.google-analytics.com/analytics.js (2 hours)
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: pagespeed insights

Post by requinix »

Vegan wrote:Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network.
I disagree with that one. They're talking about setting up the assorted files so that the browser does not try to download a new copy for some period of time. The advantage is that you save some bandwidth, but it comes with the disadvantage that if the resource changes then the browser will not get the new version. The workaround is to change the URL using a sort of nonce token, like logo.png?1, that only varies when the resource changes. I don't care for that.

A more sophisticated form of caching uses modification times or ETags. Your server is already configured to do the latter: the server calculates and sends an identifier with the resource, the browser includes the identifier in the next request, and the resource is downloaded only if it hasn't changed. The entire exchange generally takes 100-200 bytes.
Vegan wrote:How can I deal with mobile v desktop and the way facebook is good for 20 minutes and facebook is good for 2 hours
What's your question?
Vegan wrote:I was wondering how to get the caching working better, considering my site is database driven
You'd have to look into whether WordPress supports caching. Otherwise the big gain is with static files and that's already been taken care of.
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: pagespeed insights

Post by Vegan »

I have very few static files

even those are in the database
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: pagespeed insights

Post by requinix »

That statement doesn't make sense.

If those files are actual files on the server and they do not contain any sort of dynamically-generated content then they are static files. What's what static means: "lacking in movement, action, or change". Whether their paths are stored in a database or whatever is irrelevant so long as the condition holds.
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: pagespeed insights

Post by Vegan »

aside from images all of the posts are i the database

maybe the google tool is not that good
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: pagespeed insights

Post by requinix »

It's fine, it's just that its recommendation of using Expires header - if it is, in fact, a recommendation and not simply a notice that the header isn't present - tends to require more work on the developer's part (using variable URLs) for what I perceive to be not enough gain (saving a couple hundred bytes per request). Other people may believe differently.
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: pagespeed insights

Post by Vegan »

I have used the same logo for god knows how long. Why does it need to expires?

same for fonts, they are also invariant

does not make a lot of sense for my site which uses these are core assets to the whole site so they are constants
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: pagespeed insights

Post by requinix »

They're constant until they change.

If you're sure they won't change for the foreseeable future then go ahead and stick an Expires on them. Just don't pick too long of an expiration: just long enough to save clients from redownloading assets in their current browsing session.
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: pagespeed insights

Post by Vegan »

not many visitors load a second page, but all of the images flagged are very small so they load very fast
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: pagespeed insights

Post by requinix »

Then it doesn't really matter what you do.
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: pagespeed insights

Post by Vegan »

I am wondering if the tool needs to be tuned for wordpress and other popular web platforms
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: pagespeed insights

Post by Vegan »

found this while researching the topic, wonder if this approach would help with blocking stylesheets?

Code: Select all

<script>
        var cb = function() {
            var l = document.createElement('link'); l.rel = 'stylesheet';
            l.href = 'https://static.justwatch.com/static/compile_jw/assets/jw-webapp-0.11.112.css';
            var h = document.getElementsByTagName('head')[0]; h.parentNode.insertBefore(l, h);
        };
        var raf = requestAnimationFrame || mozRequestAnimationFrame || webkitRequestAnimationFrame || msRequestAnimationFrame;
        if (raf) {
            raf(cb);
        } else {
            window.addEventListener('load', cb);
        }
    </script>
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
Post Reply