Serve static assets with an efficient cache policy - External links - google-analytics

I'm trying to boost my pagespeed score, and one of my major breaks is this:
Serve static assets with an efficient cache policy.
And all under it that are left are the facebook/hotjar/analytics scripts. I'm 100% sure that I can't tell my project manager 'well screw the analytics! I'm removing them!' so I have to manage with them.
I'm pretty sure I can't force them to have a better cache (the htaccess doesn't touch things that are not loaded from the server itself) so... what can I do to force them to have a harder cache and boost my pagespeed score?

Related

My Cloudflare site is taking hours to load CSS

I created a domain on CloudFlare, a website with HTML and CSS, hosted my bucket with those files on S3, and integrated terraform for deployments. When I kick off terraform apply and run the aws cli command to update the S3 bucket, formatting changes like text show immediately but my CSS changes like font sizes and colors take several hours to be visible. How can I make both types of changes visible quickly?
I tried hard reloading my browser, clearing cache, and setting auto minify on cloudflare. I haven't tried gzipping my css and min.css files, a little afraid I might break something. I'm unfamiliar with front end development. Suggestions?
For a proxied ("orange clouded") DNS record, Cloudflare applies a default caching behaviour. This includes default cached file extensions such as CSS files. The default behaviour, caching and extensions cached are documented here.
When you do a release on your origin (S3 bucket), you could purge the cache so that the old cached versions are discarded and new ones will be pulled and cached. You can also override the cache behaviour by using Page Rules. By the way, Page Rules (and other Cloudflare settings) are also manageable via Terraform.

mod_pagespeed - internal cache purge issue

I use mod_pagespeed on my Nginx-Webserver.
When I try to test some of my pages with Google Pagespeed Insights(https://developers.google.com/speed/pagespeed/insights) there are:
1) Many errors shown the first time I do this, when the page is not opened manually with a browser before.
2) At the second scan - or if I open my page manually with a browser before - Google Pagespeed Insights shows me 90+% instantly.
Some of my sites do not have very large traffic, cause they are niche specific. I do this speed-optimation mostly for ranking purpuses. Now I am worried that Google doesn't see the 90+% when they test my site, because the first scan shows 70-80% and many errors...
Ok... so I think mod_pagespeed purges its internal cache after a while and when the first one opens the site there are no optimized files and because optimation takes to much time, the first user gets some files without full optimation. Right?
My approach nr.1:
I have done some optimation so keep the cache for 12h, but my tests show me that it doesn't work. Are here any mistakes in my attempt?
#experimental mweber 400mb 12h
pagespeed FileCacheSizeKb 409600;
pagespeed FileCacheCleanIntervalMs 43200000;
pagespeed FileCacheInodeLimit 500000;
My approach nr.2:
My hoster give me the advice to warm up the cache with a wget-script, which opens my pages from time to time. I tried that but it doesn't show any effect, so are there any requirements or parameters I have to use with wget, so mod_pagespeeed starts optimation of files?
Would be great to get some tipps and advices from you! ty :)
wget will not trigger any caching, if caching was only triggered via request then wget would not access the files to trigger them anyway as it does not process html to trigger requests on the assets.
Why are you clearing the cache so soon?

2 Servers for website and media files (Wordpress Plugin Needed)

I am needing to host media files on one server (with a different domain name) and have my website (files) on the other. I have all Wordpress base websites and am needing all current files to be moved to the other domain/server. I cannot do this manually as there are over 10,000 media files all up. Is there any plugin that allows to do this? Or any other way to do this? I am doing this to reduce the average CPU load / memory requirement. Thanks
If you are having performance issues with WordPress, my first recommendation would be to make sure you are using a caching plugin such as WP Super Cache or W3 Total Cache (I happen to use the latter). You will need to use a persistent caching option as well for the best performance, such as Memcached.
I can only speak to W3TC, but it does have an option to server your static content via a CDN such as RackSpace CloudFiles. When configured properly it will move files from your media library to the CDN, and replace the links in your content to the proper URL.
If performance is your main interest, you should also look at serving your site via Nginx and php-cgi, managed through something like spawn-fcgi. There are some caveats to using Nginx vs Apache, but once tuned the performance is far superior. You can find a guide for the configuration on the WordPress site.
Lastly you can set up a reverse proxy from your front end server to point to static files hosted on a different server - the content just passes through your front end server. This can be accomplished using Apache or Nginx, but the performance will be better in the latter. Please see my site for an example of using an Nginx reverse proxy - you would just want to proxy requests for your static files location to a different back-end server.

Dependencies that must be done away with for using CDN

I wanted to know that, is there some special requirement for a website to make use of CDN ?
i mean is there some special scheme(or atleast considerations) on which your website must be build right from the start to make use of CDN (Content delivery network).
is there anything that can stop a website from making use of CDN, for example the way it references the content files, static file paths or any other thing conceivable.
Thanks
It depends.
You have two kinds of CDN services:
Services like AWS Cloudfront that require you to upload the files in some special place that they read from (eg. AWS S3) - In this case you need have a step in your build process to correctly upload the files and handle the addresses somehow inside your application
Services like Akamai that just need you to change and tweak your DNS records so they will serve the request to your users instead of you - In this case you would have two domains (image.you.com and image2.you.com) and have the image.you.com pointing to Akamai and image2.you.com pointing to the original source of the file. Whenever a user requested an image in Akamai, they would come to you through the "back door", fetch it and starting serving that file always.
If you use the second approach it's really simple to have a CDN supporting your application.
There are a whole bunch of concerns when dealing with CDN solutions.
The first one is that a CDN can't serve a dynamic page - i.e. a page that is unique to every user. Typically, that includes PHP, ASPX, JSP, RubyOnRails etc. - so if you're hoping to support lots of users for a dynamic site, you have to come up with another solution. Some CDN providers support "Edge Side Includes" - this allows you to glue dynamic pages together with cached content on the CDN, but this creates quite a complex application.
Of course, even on a dynamic application, a CDN can still serve static files - images, stylesheets, javascript files, videos etc.
#Tucaz explains the two major options here (actually, Akamai also provides a "filestore" CDN option). If you select the second option - effectively, the CDN becomes a caching reverse proxy in front of your website - it makes sense to tweak the cache headers on your HTTP server, and tell the CDN to honour those. Make sure you set your .ASPX files to not cache!

Drupal site performance

I have used Drupal 6 for my multilingual website. I am getting issue of site performance I have enabled the cache setting of drupal but it still going slow when move from one page to other.
I have also used boost module but it’s not comfortable for multilingual website.
Please tell me any other way so I will improve performance. Thanks in advance.
your question has a whole host of answers, instead of listing all (which i would have to copy from several sites), here are a few main ones, and some resources i'd recommend:
-> Turn off all modules you are not using
-> Turn on caching
-> Try using the memcache module
-> Enable drupal JS and CSS aggregation, so we would have less files to load, meaning less HTTP requests
-> Use a CDN
-> GZIP contents
-> Minify Javascript
-> Avoid Redirects
-> Reduce Duplicate Scripts
Some Resources I would Recommend
http://wimleers.com/article/improving-drupals-page-loading-performance
http://drupal.org/node/326504
http://groups.drupal.org/node/85979
http://groups.drupal.org/node/195218
http://www.bootstrappingindependence.com/technology/how-to-improve-website-performance-with-drupal-php-mysql-and-apache/
http://www.vmirgorod.name/blog/tuning-drupal-performance
http://pronovix.com/blog/my-favorite-drupal-performance-hacks
http://fenix-solutions.com/blog/2009/12/09/tips-for-improving-drupal-performance/
http://drupalst.com/blog/improving-drupal-performance
The same issue I have faced in one of my application, I have worked on the following steps and it increases the performance which I verified through YSlow and GooglePageSpeed.
If you are using Apache, Replace Apache with NGINX as the web server for your Drupal site. This improves performance and reduces memory utilization when thousands of connections run concurrently. (Apache allocates memory to every additional connection, so it tends to start swapping to disk as concurrent connections increase)
Implementation of reverse proxy server. NGINX is a very popular reverse proxy server for Drupal sites. Implementing a reverse proxy server removes the burden of handling Internet traffic from your application server and allows other performance‑enhancing steps: caching of static files and the use of multiple load‑balanced application servers.
Implementation of CDN (Content Distribution Network)
Implementation of browser level caching at server level
Should enable Compression of images, CSS and Javascript files.
You can use Akamai for node/page level caching as a result it will increase the performance.
Use image sprites (css3embed), avoid iframes if you are using
Index database tables (use dbtuner)
Use of adding an Expires header
Disable DbLog module if not in use.
Move your assets at bottom
Reduce DNS lookups
Hope it would help.
Thanks
you need realy fast hosting, i recommend use nginx with phpfpm. without any var or opcode cacher your perfomance will be just incredible. im my vps i have speed up big drupal site to 200ms per page
and of course you must to audit your site for slow queries (big views, many blocks or php code).

Resources