Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8895699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:51:06+00:00 2026-06-14T23:51:06+00:00

I’m looking to collect data on page load speeds via Google Analytics, and would

  • 0

I’m looking to collect data on page load speeds via Google Analytics, and would like to split this between pages that have been returned having HIT the Varnish cache, and those that have MISSED the cache.

Before looking into this I just assumed I’d get JS to have a look at the varnish headers in the page response, and create a GA custom var to track this on a per-page basis. Of course, JS doesn’t have access to the page headers, so I’m at a bit of a loss currently. I’ve made server-side GA tracking work ing the past (via php-ga) but this needs to tie in to real-world page load time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:51:07+00:00Added an answer on June 14, 2026 at 11:51 pm

    Just a thought, but you could set a cookie in the “vcl_deliver” subroutine. Something like this:

    sub vcl_deliver {
        if (obj.hits > 0) {
                set resp.http.Set-Cookie = "VarnishHit=Yes;Path=/;";
        }
     return (deliver); }
    

    This basically says: if the obj has more than one hit, set a cookie saying so. You will need to make sure you do not over write any other cookies, so maybe just concatenate this to you existing Set-Cookie, if you are using cookies. For more info on the obj.hits look here:
    https://www.varnish-cache.org/docs/3.0/reference/vcl.html

    Here is the line that matters:

    obj.hits
    The approximate number of times the object has been delivered. A value of 0 indicates a cache miss. This variable is also available in vcl_deliver.

    That will give you access to this information from within Javascript using the document.cookie variable. I believe that jQuery has some plugins to make this easier, here is one I found: https://github.com/carhartl/jquery-cookie on Google. Once you can check for the existence of the cookie in JS you should be able to use the GA API to log a event. I hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
For some reason, after submitting a string like this Jack’s Spindle from a text
I would like to run a str_replace or preg_replace which looks for certain words
I would like to count the length of a string with PHP. The string
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.