• 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.

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, 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

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • Changing Data With cURL for OpenStack Swift (HP Cloud CDN)

    Changing Data With cURL For Object is Quite Easy in OpenStack Swift. Here Are Examples With HP Cloud CDN To Make it Clear. Official Examples Are Bad.

  • HTTP/2 Server Push : Nginx & WordPress

    Here is a Clear, Easy Guide on HTTP/2 Server Push. Nginx & WordPress is Commonly used Combination For HTTPS on Cloud to Dedicated Servers.

  • How To Install Apache2 on Ubuntu 18.04 With Let’s Encrypt, HTTP/2, HSTS

    Here is Detailed Guide on How To Install Apache2 on Ubuntu 18.04 With Let’s Encrypt, HTTP/2, HSTS With Commands and Configurations For Most Secured Setup.

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

Get new posts by email:

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 (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • How Search Engine WorksNovember 30, 2023
  • Data Mining: An OverviewNovember 30, 2023
  • What is Meant by Doxing?November 29, 2023
  • What is Market ShareNovember 29, 2023
  • Affiliate Marketing Condition/Commission ModelsNovember 28, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

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

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