• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here: Home » Cache Aware HTTP/2 Server Push On Apache2, WordPress

By Abhishek Ghosh June 10, 2017 8:43 am Updated on June 10, 2017

Cache Aware HTTP/2 Server Push On Apache2, WordPress

Advertisement

We discussed about HTTP/2 Server Push. Apache2 is superior web server software compared to Nginx and it supports HTTP/2 Server Push. Here are few examples of HTTP/2 Server Push on Apache2 running WordPress (we are not talking about simple Link Preload) which can make your webpage to load faster over HTTP/2. Properly implementing HTTP/2 Server Push not exactly easy work. At the end, we will learn to create Cache Aware HTTP/2 Server Push On Apache2 for WordPress.

Cache Aware HTTP:2 Server Push On Apache2, WordPress

 

Many websites talk about Link Preload not real HTTP/2 Server Push. HTTP/2 Server Push also contains the keyword Link Preload but HTTP/2 Server Push can be separated from HTTP/2 Server Push, the later is too serious server side matter. Even they included rel=preconnect inside some of those articles with lot of wrongs/imperfectness in code for Apache2. Our and many small, medium websites are far well optimised, although we have least resources and always at developmental mode. They do publish odd things around page speed optimisation too. There are lot of resources including from Apache2 related peoples small websites. But those websites are “mainstream” and popular. The wrong thing runs.

We are talking about this RFC :

Advertisement

---

Vim
1
https://tools.ietf.org/html/rfc7540#section-8.2

Also look at the content under the subheader “Server Push (HTTP/2)” :

Vim
1
https://www.w3.org/TR/preload/

 

Basic Idea About Cache Aware HTTP/2 Server Push On Apache2, WordPress

 

First thing is that, you need to have Apache2 installed in our way. That repo has importance over hundreds of distro specific packages.

HTTP/2 Server Push is nothing but like we inline CSS, Js – we are pushing it over HTTP/2. Which resource you want to Push depends on waterfall analysis (on webpagetest.org) of your webpage. Usually some resource(s) which is/are at the bottom of the waterfall can be pulled up with HTTP/2 Server Push. It is definitely bandwidth costly for a client with 256 kbps modem. The directive for HTTP/2 Server Push contains the Link Preload as there is HTTP/1.1 as other users so that it becomes plain “preload” on HTTP/1.1. It is not possible to think anything more at this moment as RFC spec. But HTTP/2 Server Push is far superior than plain Link Preload – we can specify not to push based on cache, specify cache, ask not to fallback to plain preload etc. So there are differences with inline CSS. Most Page Speed tools can not understand all the directives at present. There is a matter of “perception” of experience. Inlining CSS is best so far as not even 50% devices using HTTP/2.

WordPress has little to do directly with HTTP/2 Server Push, rather there are common files at frontend which are suitable candidate to HTTP/2 Server Push. That mixture of inline, HTTP/2 Push is maximum optimisation on June 2017. Oddly, in most cases, you’ll find HTTP/2 Server Push to be useless (there are too many devices, too many complicated matters to consider).

 

Examples Of Cache Aware HTTP/2 Server Push On Apache2, WordPress

 

We are talking in the context of mainly httpd.conf/apache2.conf or .htaccess. To enable most simple example push to load will be, with example of CSS and Js :

Vim
1
2
Header add Link "</wp-content/plugins/your-plugin/js/min/min.js>;rel=preload;as=script"
Header add Link "</wp-content/plugins/your-plugin/assets/css/common.css>;rel=preload;as=style"

The above on HTTP/1.1 will be simple old preload. We can make it only for HTTP/2 :

Vim
1
2
Header add Link "</wp-content/plugins/your-plugin/js/min/min.js>;rel=preload;as=script;x-http2-push-only"
Header add Link "</wp-content/plugins/your-plugin/assets/css/common.css>;rel=preload;as=style;x-http2-push-only"

The most perfect solution at present would be to set a cookie, when the example.js file is pushed and also directive is to check that cookie for the next time, so that the push is only when the cookie is not present :

Vim
1
2
3
4
5
6
7
<IfModule http2_module>
   SetEnvIf Cookie "scriptloaded=1" scriptloaded
   <filesMatch "\.([hH][tT][mM][lL]?)">
   Header add Link "</wp-content/plugins/your-plugin/js/min/min.js>;rel=preload;as=style" env=!scriptloaded
   Header add Set-Cookie "scriptloaded=1; Path=/; Secure; HttpOnly" env=!scriptloaded
   </filesMatch>
</IfModule>

Logically I want to push only on HTML files of W3TC. You need to work with the filesMatch directive as it can interfere with W3 Total Cache or permalink. Of course you can split it to make easy and add on .htaccess :

Vim
1
2
3
4
5
<IfModule http2_module>
   SetEnvIf Cookie "scriptloaded=1" scriptloaded
   Header add Link "</wp-content/plugins/your-plugin/js/min/min.js>;rel=preload;as=style;x-http2-push-only" env=!scriptloaded
   Header add Set-Cookie "scriptloaded=1; Path=/; Secure; HttpOnly" env=!scriptloaded
</IfModule>

The above is near perfect. If has cache will not push, but will push when cache is clear. It also prevents any chance of injection, poisoning cache etc.

If you cURL, you will get it, as example :

Vim
1
curl -I https://thecustomizewindows.com/category/computer-and-internet/digital-photography/

Test on Google Chrome’s Developer > Javascript Console > Network. When cache is present, that means you are reloading the page, or like browsing now, it will not push. Clear your cache, you’ll see the file is pushed.

This Article Has Been Shared 219 Times!

Facebook Twitter Pinterest
Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Orthopaedic Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Cache Aware HTTP/2 Server Push On Apache2, WordPress

  • WP Super Cache With Rackspace Cloud Files CDN (Open Cloud)

    WP Super Cache With Rackspace Cloud Files CDN guide is an update due to change of technology by using Open Cloud.The Streaming Media need to be used separately.

  • AdSense Asynchronous Ads with Responsive Design

    AdSense Asynchronous Ads with Responsive design is a quite difficult to manage or implement. Here are some ideas which might help you for HTML5 website.

  • Choosing WordPress and HTML Template for a Website

    Choosing WordPress and HTML Template for a Website is not really that easy that it might sound. This quite difficult as both has limitations of their own.

  • bbPress Nginx Subdirectory Rewrite Rules (HP Cloud)

    bbPress Means WordPress. In This Article,bbPress Nginx Subdirectory Rewrite Rules is Assumed For a Fresh Subdirectory WordPress Installation.

  • Google Accelerated Mobile Pages (AMP) and WordPress

    Google’s Guinea Pig Experiments with the Webmaster is Not New. Read for Coding Stuffs on Google Accelerated Mobile Pages (AMP) and WordPress.

Additionally, performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

You can subscribe to our Free Once a Day, Regular Newsletter by clicking the subscribe button below.

Click To Subscribe

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (20K Followers)
  • Twitter (4.9k Followers)
  • Facebook (5.8k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.2k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • What is Inertial Navigation System? January 25, 2021
  • What is Miniaturization? January 24, 2021
  • What is Domain-Driven Design (DDD)? January 23, 2021
  • Top 10 Anti Hacking Software for Microsoft Windows January 22, 2021
  • What is Software Modernization? January 21, 2021

 

About This Article

Cite this article as: Abhishek Ghosh, "Cache Aware HTTP/2 Server Push On Apache2, WordPress," in The Customize Windows, June 10, 2017, January 25, 2021, https://thecustomizewindows.com/2017/06/cache-aware-http2-server-push-on-apache2-wordpress/.

Source:The Customize Windows, JiMA.in

 

This website uses cookies. If you do not want to allow us to use cookies and/or non-personalized Ads, kindly clear browser cookies after closing this webpage.

Read Cookie Policy.

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

Copyright © 2021 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy