How to manage page caching to serve different AdSense units for Mobile and Desktop

I’m trying to cache the pages of my website, which are responsive and show the same contents for Desktop and for Mobile, with the exception of the location of the AdSense units if the visit is from Desktop or from Mobile:

  • for Desktop, I place the first ad (a 728×90 banner) just under the page title
  • for Mobile, the first ad is a below-the-fold 300×250 unit

The rest of the HTML contents are identical, except the AdSense code for the first ad. So I cannot cache the pages and I must query the database with the consequent load increment.

I wondered if any of you had similar experiences. Would you place the same AdSense code (e.g. responsive units) for the first ad (for both Desktop and Mobile), just in the below-the-fold of the mobile pages?

CDN & Caching Blocking Email Automation

I’m using Groundhogg with WordPress. I have caching through Litespeed’s plugin, Cloudflare (DNS records are only in my CPanel), and the server itself. All three, together and individually, block emails being sent using Groundhogg. Groundhogg is an email marketing and automation tool. Users cannot get through the basic opt-in funnel. They’ll submit the form and get the confirmation email. When they click the confirm link, they’re oddly taken to a “manage your preferences” page instead of a…

CDN & Caching Blocking Email Automation

Google is caching my homepage almost properly but not other pages

My website is built on NodeJS with ReactJS as frontend and has server side rendering.

Problem 1: Home page is cached properly by Google but other pages are cached without their CSS.

Problem 2: Blogs which are brought dynamically are not shown in the cache.

Link : https://www.google.com/search?q=site%3Aamitkk.com&oq=site%3Aami&aqs=chrome.0.69i59j69i57j69i58.12895j0j7&sourceid=chrome&ie=UTF-8

Thanks in advance

Amit

Error caching static js files in my htaccess file. What does this error mean? [duplicate]

I have this in my .htaccess file:

<IfModule mod_expires.c>   ExpiresActive on  # Perhaps better to whitelist expires rules? Perhaps.   ExpiresDefault                          "access plus 1 month"  # cache.appcache needs re-requests in FF 3.6 (thx Remy ~Introducing HTML5)   ExpiresByType text/cache-manifest       "access plus 0 seconds"  # Your document html   ExpiresByType text/html                 "access plus 0 seconds"  # Data   ExpiresByType text/xml                  "access plus 0 seconds"   ExpiresByType application/xml           "access plus 0 seconds"   ExpiresByType application/json          "access plus 0 seconds"  # RSS feed   ExpiresByType application/rss+xml       "access plus 1 hour"  # Favicon (cannot be renamed)   ExpiresByType image/x-icon              "access plus 1 week"  # Media: images, video, audio   ExpiresByType image/gif                 "access plus 1 month"   ExpiresByType image/png                 "access plus 1 month"   ExpiresByType image/jpg                 "access plus 1 month"   ExpiresByType image/jpeg                "access plus 1 month"   ExpiresByType video/ogg                 "access plus 1 month"   ExpiresByType audio/ogg                 "access plus 1 month"   ExpiresByType video/mp4                 "access plus 1 month"   ExpiresByType video/webm                "access plus 1 month"  # HTC files  (css3pie)   ExpiresByType text/x-component          "access plus 1 month"  # Webfonts   ExpiresByType font/truetype             "access plus 1 month"   ExpiresByType font/opentype             "access plus 1 month"   ExpiresByType application/x-font-woff   "access plus 1 month"   ExpiresByType image/svg+xml             "access plus 1 month"   ExpiresByType application/vnd.ms-fontobject "access plus 1 month"  # CSS and JavaScript   ExpiresByType text/css                  "access plus 1 year"   ExpiresByType application/javascript    "access plus 1 year"   ExpiresByType text/javascript           "access plus 1 year"    <IfModule mod_headers.c>     Header append Cache-Control "public"   </IfModule>  </IfModule> 

When I do a speed test, I get a C in “cache static content”, because of this:

Leverage browser caching of static assets: 79/100 Learn More

FAILED – (No max-age or expires) – https://static.cloudflareinsights.com/beacon.min.js

FAILED – (5.0 minutes) – https://www.google.com/recaptcha/api.js

FAILED – (15.0 minutes) – https://www.googletagmanager.com/gtm.js?id=GTM-P55kj6J

WARNING – (1.8 hours) – https://www.google-analytics.com/analytics.js

WARNING – (24.0 hours) – https://fonts.googleapis.com/css?family=Chewy|Open+Sans:300,400|Merriweather:400,700

WARNING – (2.0 days) – https://learningeveryday.org/cdn-cgi/scripts/5c54i28/cloudflare-static/email-decode.min.js

WARNING – (2.0 days) – https://ajax.cloudflare.com/cdn-cgi/scripts/708564e/cloudflare-static/rocket-loader.min.js

WARNING – (2.5 days) – https://learningeveryday.org/includes/lazyload.min.js

WARNING – (2.5 days) – https://learningeveryday.org/includes/tinymce.min.js

WARNING – (2.5 days) – https://learningeveryday.org/includes/listo.min.js

WARNING – (2.5 days) – https://learningeveryday.org/includes/jquery.validate.min.js

WARNING – (2.5 days) – https://learningeveryday.org/includes/js/popper.min.js

WARNING – (2.5 days) – https://learningeveryday.org/includes/js/jquery-ui.min.js

WARNING – (2.5 days) – https://learningeveryday.org/includes/js/jquery-3.3.1.min.js

WARNING – (6.9 days) – https://learningeveryday.org/style.min.css

WARNING – (6.9 days) – https://learningeveryday.org/includes/bootstrap.min.css

Why I’m getting these errors? I thought that I’ve already cached js files…

Calculating effective access time in memory caching context

I have went through various problems involving time required to access required data in the context of caching.

They use different formulae in different problems. For example, this answer suggests these formulae:

effective-access-time = hit-rate * cache-access-time                   + miss-rate * lower-level-access-time    effective-access-time = cache-access-time + miss-rate * miss-penalty 

Let me rewrite them:

  1. $ T_{eff}=H_{L1}\times T_{L1} + (1-H_{L1})\times T_{LowerLevelMemories}$
  2. $ T_{eff}=T_{L1}+(1-H_{L1})\times T_{L1MissPenalty}$

where,
$ H_{L1}$ is L1 cache hit rate
$ T_L1$ is L1 cache access time
$ T_{LowerLevelMemories}$ is time to access lower level memories
$ T_{L1MissPenalty}$ is L1 cache miss penalty

About when to use which formula, the answer says:

  • use first formula when lower level memory access time is given and
  • 2nd formula when miss penalty is given.

Is it so?

Let me put $ T_{LowerLevelMemories}=T_M$ , a main memory access time in formula 1. Also, I feel formula 1 ignores that we do indeed access L1 cache when cache miss occurs. So we should also multiply $ (1-H_{L1})$ by $ T_{L1}$ . So formula 1 becomes:

$ T_{eff}=H_{L1}\times T_{L1} + (1-H_{L1})\times (T_M+T_{L1})$ $ =H_{L1}\times T_{L1} + T_M+T_{L1} -H_{L1}\times T_M-H_{L1}\times T_{L1}$
$ =T_{L1}+(1-H_{L1})\times T_M$

This last equation resembles formula 2 above. Also we can interpret that $ T_M$ is exactly the L1 miss penalty. So I feel, we should

  • use formula 2 when we assume L1 is accessed even during miss and
  • formula 1 when we assume L1 is not accessed during miss

However this does not align with what answer has to suggest as quoted above. Am I correct with how to make decision when to use which formula or the quoted suggestion from the answer is correct?

Your Opinions on Caching

My webpages are pretty lean and are scoring 100 in Google's PageSpeed test. They load in less than one second.

Your opinions & advice? — Should I do some caching in my .htaccess to speed them up even more? Or should I just leave good results alone and not tamper with them? (I'm not high-tech and might do something harmful) Sample page: https://www.jimfeeney.org/broken-interpersonal-relationships-healed.html

Magento 2.3.1 varnish and cloudlfare – pages not caching as expected

We have a Magento 2.3.1 store that uses CloudFlare and has Varnish enabled. If we use wget or curl to load a page, that page is cached in Varnish if we try wget or curl again on that same page.

However, if we then test that URL via a browser, the page is not cached. It is then cached after the first browser visit, and then remains cached on reloads from a browser.

We added the CF+Varnish rules as listed at: https://support.cloudflare.com/hc/en-us/articles/200169376-Can-I-use-Cloudflare-and-Varnish-together-

but that did not seem to make a difference. We’re using the recommended Magento default.vcl file that is generated.

Any ideas what could be stopping a wget/curl from loading a page into the Varnish cache such that any request from a browser would be served that cached page instead of causing Varnish to cache the page again?

Service worker / caching a whole API in a Flask app?

I’m building a small scale app based on the Flask micro framework. In it, I have a service worker that caches the basic shell of my app (HTML, CSS and JS). However, I have dynamic content that is updated when some event occurs (i.e. click on a button which sends a request to the API endpoint, the backend does a bit of filtering and then it sends the processed data back to the UI).

How can I approach the caching of this API and is that possible at all? One way I thought of was to cache request by request until, gradually, I cache all of the possible responses. However, I’m not sure if there is another solution to make my app more accessible when in offline mode.