• 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 925 Times!

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

  • 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

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

  • Cyberpunk Aesthetics: What’s in it Special January 27, 2023
  • How to Do Electrical Layout Plan for Adding Smart Switches January 26, 2023
  • What is a Data Mesh? January 25, 2023
  • What is Vehicular Ad-Hoc Network? January 24, 2023
  • Difference Between Panel Light, COB Light, Track Light January 21, 2023

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 28, 2023, https://thecustomizewindows.com/2017/06/cache-aware-http2-server-push-on-apache2-wordpress/.

Source:The Customize Windows, JiMA.in

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

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT