add expire headers for static content google recaptcha - html5boilerplate

I tested my site using Yslow and it states
There are 7 static components without a far-future expiration date.
https://www.google.com/recaptcha/api.js?onload=myCallBack&render=explicit&hl=en
http://www.searchanise.com/widgets/v1.0/init.js
Now I have seen that there is the HTML5Boilerplate project that has an excellent .htaccess file with examples but I do not see how that can apply to findings on my site.

You can't control expires headers or anything for content you're loading from other sites. You can only control things on your own site (that's what the .htaccess file from the boilerplate project would help with).
What you can do is review all those components being loaded from other sites to make sure they are still needed. I list some other strategies in this answer: https://stackoverflow.com/a/22057650/9965

Related

Serve static assets with an efficient cache policy

Help needed!
I am struggling setting the cache policy on my wordpress website.
I have tried to set the expirations manually in .htaccess and I have tried several plugins.
Nevertheless Google Page Speed Insights keeps displaying the message "Serve static assets with an efficient cache policy".
Is it possible to sort of manually add a cache policy (e.g. via .htaccess) for a specific line in Google Page Speed Insights?
Any help or suggestions will be much appreciated!
"Serve static assets with an efficient cache policy".
Most likely you are getting this message for resources which are not hosted by your website and is coming from external sites such as Google Analytics code or any other third party code. If that is the case you won't be able to do much and you can simply skip the "Serve static assets with an efficient cache policy" suggestion.
If the suggestion is for your own hosted content and you are not able to resolve even after making changes to .htacces files the problem could be in your web hosting and you need to contact them for resolution.

Host complete WordPress website in Amazon CloudFront or any other CDN

What I would like to do
According to a Amazon Senior Architect to whom I spoke recently, it is possible to cache dynamic website content in Amazon CloudFront.
The way I understand how this could work, is that in addition to doing a page cache of each page which has been accessed, cache the page in CloudFront too.
What I have tried
I have experimented a lot with W3 Total Cache and its settings but did not find a solution to this problem. I also have tried to set up CloudFront directly in the AWS control panel but did not find a way to cache the static result (html?) of WordPress's php calls.
Question
How would you tackle the issue?
How can I cache a static version of WordPress's dynamic pages in CloudFront or any other CDN?
Here is a concept plugin which aims to do this:
https://github.com/PeterBooker/wp-cloudfront-helper
most CDNs advertise that they can cache dynamic web sites. Unless they have very specific information about the pages they need to serve, they can't. There are situations where the "penalty" of a CDN for a dynamic page isn't that bad, but having an additional hop in-between the web server and the end user can only be faster in some very specific situations. The main reason is the absense of a Last-Modified header for the generated pages.
From my experience working with (at) CDN providers, the most performant way to include a CDN is to use a different hostname for the static assets and point that hostname to the CDN with your web server as the origin server.
Jan

Magento CSS not updating after copying site to another server

I done things a bit backward developing my new site, don't ask me why! But i built the site on the live server it will be hosted on first and the other day i created a sub-domain to hold a copy of the website so i can use it as a sandbox environment and test new plugins, to get PayPal working etc
I followed this tutorial
So it all worked fine! i have a copy of my site on a subdomain working. I had the infamous admin login redirect to itself issue but i sorted that, the reason it wasnt working was because i had my caches disabled in magento before i copied the site. So i had to enable them again in order to gain access ( If anyone knows why this is please share).
So my problem now is, i am updating the design of my website using the css and images in the skin folder. The problem is i update something in the css and load it onto my server and into the subdomain skins folder but nothing changes on the frontend UNTIL about 15 minutes later and me clearing all caches hundreds of times!! i really don't understand whats happening?
The links to my css/js and image folders are all correct in the head of the website. It's just like a time delay between me changing something in the css and the website updating itself.
Any information would be greatly appreciated.
Kind regards
Tom
Have you also disabled cached on Magento Admin? Perhaps you can try reloading the site on a non-cached based version of browsers (e.g. Incognito Mode in Google Chrome).
Your browser is also caching the external css files which is basically good for saving bandwidth of server and reducing page loading speed. But, for development purpose, you need to avoid css caching. On firefox or IE, you can use CTRL+F5 to reload a webpage without cached css.
If you do not want to use CTRL+F5, you can also add timestamp to your css file as URL parameter.
For example, style.css?<?php echo time();?>
You can also use Apache module to expire the caching.
.htaccess
ExpiresByType text/css "access plus 1 second"
http://httpd.apache.org/docs/2.2/mod/mod_expires.html

Use Wordpress for static WebSite

I want to create a static website and use wordpress only to "compose" the website. I want to create a template that only use the same header and footer and change the content of the page (home, contact ecc dcc). My site is not a blog or any other type of site that needs CMS I only want to use Wordpress to have only one header and footer and don' t want to change it in all pages when I need some customization to it. I hope I was clear enough! Thanks!
You can create a site in WordPress (or any other CMS) on your own local computer, then save a copy using an offline browser such as HTTrack. Then upload the HTTrack saved HTML to your webhost.
This will make your site faster, as there will be no need to execute PHP on page requests, and the webserver will use its default caching headers. (Also, you get the option of using a cheaper hosting without support for PHP and MySQL.)
Any time you change the site, you'll need to edit the live WordPress version, save it again, and reupload the files.
Disclaimer: I'm dev of the WP Static HTML Output project.
It's been around for a few years and still has 5k+ active installs, but jazzing it up with some more features now and its whole purpose is to allow you to use WordPress for your site development and export to a static HTML version for speed, security and portability.
For the OP, the basic FTP publishing option may be of use. For more advanced cases, there are services like Netlify which can auto build/deploy your static site from a Git branch.
In the Settings | Reading admin page, choose a static page for your front page display. Build your site out using Pages instead of Posts. Each Page will inherit your site's standard header and footer. Create your Main Menu from the Appearance | Menu admin page to hook together your Pages. Use widgets and standard HTML links as needed. Then dress up your site with one of the many available themes.
A bit late to the table on this one but it seems that Wordpress is totally overkill for a static site. Wordpress pages can be cached with cache plugins but when any Wordpress site loads there are a number of scripts and custom php functions that run each time a page loads.
Why not just build a flat file website and simply include your header and footer with PHP? Far quicker to set up and based on your question it seems that this is simply what you need.
Added to this, you won't have an admin area for your site or a database, just the files on the server - surely this makes your site less hackable too. An added bonus is a really easy site to version control with Git or SVN.
If there's someone else out there wanting to use a static site generator over Wordpress, here's a script called WP Static which does just this: http://mossiso.com/code/make-wordpress-static
Another great solution to this problem is to use a specific software that is created exactly to do that. For Mac, for example, there's a software called Hammer that "compile" your site every time you save and includes your header and footer to the page. Is really useful.

SSL and relative URLs in site links and redirections

I have been working on a website in beta phase for some time now, and am finally about to launch it. There are several links, anchor tags, with relative URLs throughout the site that link to the admin and cart sections of the website, and now they have to be SSL secured.
Also, same question for relative URLs in Response.Redirect("~/../..");
When a user is browsing over http, is there anyway to redirect them to a page with https connection using a relative URL? It seems like poor practice to code absolute URLs for links and redirections for the purpose of SSL. If the domain name changes, I have to rewrite them all. Plus, if I want them to work on my localhost, I would have to change them every time I upload to server. There must be some solution.
Switching Between HTTP and HTTPS Automatically is a very good code to use for the implementation of switching logic fast and easy - and not change your existing code.
Similar: Preparing my ASP.NET / MVC site to use SSL?
These helper methods by Rick Strahl will help you
http://www.west-wind.com/weblog/posts/2007/Sep/18/ResolveUrl-without-Page
Pay special attention to ResolveServerUrl.
Depending on what version of IIS you are running, you could always offload this functionality to the webserver. Check out the URL Rewrite module here.

Resources