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

Reduce server hits with JS history API #17

Closed

Conversation

peterwilsoncc
Copy link

This patch aims to speed up page loads by removing the extra hit required by a 301 redirect.

The patch loads the requested page/post on the shortlink, the JavaScript history.replaceState function is used to display the canonical URL to the visitor.

Individual results may vary but on my server it looks like it will save around 500ms.

Peter Wilson added 2 commits November 27, 2014 11:44
This reduces the number of calls to the server to speed up content loading for the user.
@willnorris
Copy link
Collaborator

I'm all for making this kind of thing possible, but am hesitant to make it the default behavior. While it should work fine for browsers, I'm not sure what the implications would be for search engines, since you now have two URLs serving identical content with 200 OK responses. There are also URL pre-processors that follow redirects to get to the canonical URL for a post which this would break (I have an android app that does that, and I think brid.gy does that as well).

So if we need to add the hum_process_redirect filter to make it possible for a separate plugin to do this, that's fine. But I wouldn't want to change the default behavior.

@peterwilsoncc
Copy link
Author

Makes sense, I'll update the patch & add a comment when I've done so.

WP adds canonical meta tags for big search, but I didn't think about the other use cases.

Sent from my mobile phone

On 29 Nov 2014, at 6:17 am, Will Norris notifications@github.com wrote:

I'm all for making this kind of thing possible, but am hesitant to make it the default behavior. While it should work fine for browsers, I'm not sure what the implications would be for search engines, since you now have two URLs serving identical content with 200 OK responses. There are also URL pre-processors that follow redirects to get to the canonical URL for a post which this would break (I have an android app that does that, and I think brid.gy does that as well).

So if we need to add the hum_process_redirect filter to make it possible for a separate plugin to do this, that's fine. But I wouldn't want to change the default behavior.


Reply to this email directly or view it on GitHub.

@pfefferle
Copy link
Owner

I think an action to replace the default redirect still makes sense. There are two options:

  1. add a hum_pre_redirect action before the wp_redirect
  2. replace the wp_redirect with a hum_process_redirect action and move the wp_redirect to a default handler

What do you think?

@peterwilsoncc
Copy link
Author

Yeah. I haven't had a chance to work on this but coincidently going on a WP dev weekend this weekend so will add it to the list :)

@willnorris
Copy link
Collaborator

I'm fine with either of @pfefferle's options (you guys pick). I would also note however that the overhead of returning a 301 redirect and making a second HTTP request should be completely negligible with HTTP/2.

pfefferle added a commit that referenced this pull request Sep 2, 2015
@pfefferle pfefferle closed this Jan 14, 2016
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

Successfully merging this pull request may close these issues.

3 participants