Step 4: Changes settings

Only upload every X fileThis can improve load time because your own server can deliver files, too. Not every single file should be hosted on Google Drive. It is better to spread them across multiple servers. On most cases 3 is a good number.

Cache time
Please specify how long the URLs should be cached. Set to 0 to deactivate. Leave it blank to store the files for an indefinite period. It’s recommend to leave this empty because static files do not change very often.

Purchase Code
In order to get automatic updates you should copy and paste your purchase code here. If you do not know where to get your purchase code, please click here: Where to find your purchase code.

What does the button ‘Clear local CDN cache’ do?

If anyone visits a page of your website, the plugin searches for files that can be uploaded to Google Drive.

If the file is not yet uploaded to Google Drive the plugin will put it down into the cache-database for a later upload.

Every hour the plugin reads all these entries from the cache-database to sync files to your Google Drive that have not yet been synced.

By clicking “Clear local CDN cache” you can clear the cache-database which has the relation between local and CDN-file.

What does the button ‘Remove all cached files from Google Drive’ do?

It removes all files that have been uploaded by the plugin.

What does the button ‘Sync local CDN’ do?

If anyone visits a page of your website, the plugin searches for files that can be uploaded to Google Drive.

If the file is not yet uploaded to Google Drive the plugin will put it down into the cache-database for a later upload.

Every hour the plugin reads all these entries from the cache-database to sync files to your Google Drive that have not yet been synced.

You can manually start syncing the files that have been written to the cache-database by clicking the “Sync local CDN”-button.

What does the button ‘Sync my media library now’ do?

This uploads all files that are in your media library to Google Drive. In most cases this is not needed.

Are there any (traffic/bandwidth) limitations?

Regarding the upload of files, yes. There are some limitations: Google limits the maximum daily requests to the API to 10’000’000. So if you have a very (I mean, really very very large site) with more than 10’000’000 files in your media library (including static files of your installed plugins and themes) the plugin will not work on the 10’000’001 file :-)

If you’re “over quota” then it will not be possible to sync files and update files to the Google Drive any longer.

“(…) Google Drive website publishing feature does have quotas in place.While we can’t share the actual numbers, please note that websites hosted on Google Drive will be able to handle large loads which should meet the needs of most users publishing personal content.

However this is not intended for serving resources for very-high traffic websites (e.g. millions visits a day). Also there is currently no way to increase your quota. If you are looking for a professional solution for a high traffic website have a look at Google App Engine.”

Besides images, what other files can this support?

At the moment the plugin tries to find jpeg, jpg, gif, png and css files. You can add your own file extensions but Google Drive will sometimes bring up some MIME-Type errors. This means that it does not recognize special files (like .otf, .woff, etc.). It does not mean that these filetypes cannot be delivered via the Google servers.

Can this serve image data that is in a plug in sub folder and not the upload folder?

Yes. As long as your plugins folder is inside the wp-content folder it should also upload all the static files from there. But only when the static files are shown on the frontend. The plugin does not upload static files that are displayed on the admin panel only.

I’m curious how easy it is to uninstall this? You say it changes the image links to Google Drive links, so I’m assuming it changes the actual files your website is running from. But if you uninstall this, will it change them back?

I think this is hard to explain. But I’ll try. In PHP there is a function that allows us to trap the entire HTML code before it is sent to the browser. In this stage we search for file URLs and replace them with the Google Drive URLs. Then the whole HTML code will be sent to the browser. So if you deactivate the plugin there is no PHP-code that can replace the URLs. In fact: everything is at it was before There are no changes made to the sourcecode of your posts, your theme or anything else.

I cannot grant permission to my Google Drive. What’s wrong?

Of course a lot can be wrong. Please refer to the error log messages that got thrown.

The versions prior 1.1.1 had a problem while creating the folder on your Google Drive that is needed to get the plugin to work. Please update to at least version 1.1.1 to solve this issue.

Is it possible to abort the sync process?

When you click the “Sync my media library now” button and want to abort the sync process, just leave the site. This button hits a Javascript which will break if the page gets reloaded or when you just go away off the current page. But it will finish the last upload (which can result in upload a maximum of 3 more files. This is because the plugin always uploads 3 files at once).

When you click the “Sync local CDN”-Button the sync starts in the background. When you disconnect during the sync process the sync stops and it does not upload anything else because there is no connection to the Google Drive any more.
But it can be (like I wrote above) that the plugin is currently in the loop and uploads 3 more files after disconnecting because it always uploads 3 files at once.

Please also note that the sync process starts automatically every hour to make sure that everything is up-to-date on your Google Drive.

Does it work with WP Super Cache?

Yes, it does. We do always use it together with WP-Super Cache. But it will also work with any other cache plugin (like W3-Total-Cache).

Please note the following:

You don’t need any special settings to set the Google Drive as WordPress CDN Plugin up with WP-Super Cache.

If your page cache is very aggressive (let’s say the page cache expires only once a week) it could be that the CDN-Plugin cannot upload new files as fast as normal. This is because the page cache avoids to call PHP. Without calling PHP the CDN-Plugin cannot collect any data. This means that static file URLs can only be collected after the page cache has expired. However this does not mean that your static files never get uploaded. It just means that it takes longer.

I’m getting the following error: Warning: file_exists() function.file-exists: open_basedir restriction in effect. File(/tmp/Google_Client/ad/ad41610b13f338f946b8e9e744ec68f0.lock) is not within the allowed path(s): (/var/www/myexample.com/:/var/www/tmp/) in /var/www/myexample.com/public_html/wp-content/plugins/google-drive-cdn/classes/google-api-php-client/src/cache/Google_FileCache.php on line 37. What should I do?

The problem here is that the webserver you’re using to run WordPress is misconfigured. The Google Drive API sometimes wants to cache some files directly into a temporary folder for speed things up. But the temporary folder on your webserver is not writeable by PHP which results in the above mentioned warning.

In versions < 1.3 you can do the following:

Open the wp-content/plugins/google-drive-cdn/classes/google-api-php-client/src/config.php file with your favourite text editor

Note #1: the string ‘/var/www/myexample.com/public_html/wp-content/’ should be replaced with the exact path on your server as they are not the same on every server.

Note #2: the wp-content folder should be writeable by the webserver (in most cases this is the standard). If the folder you’re linking to is not writeable you will again get the same error.

Note #3: this settings will be overwritten when you update the plugin.

In version >= 1.3 you can set the path via the settings page directly.

Does it work with SSL?

Yes and no. At first, Google Drive will always deliver files via SSL. At the moment with an 128 byte certificate. If you’re using your own certificate (and maybe a stronger one) it can be that the browser will not show the security-symbol any longer.

What is the ‘Mixed Content Blocker’ problem?

Google Drive delivers all files via secure SSL. If you are not using SSL on your domain you should remove CSS files from the file extensions field. This is because it can lead to the “Mixed Content Blocker” problem some browsers have when your CSS file tries to import Non-SSL files via the @import function. Some Browser will block that (because it can be a security issue). You can read more about the Mixed Content Blocker issue on Stackoverflow.

The plugin will automatically stop referring to CSS files on Google Drive if it detects that your domain does not support SSL.

I’m getting the error 403 Access Not Configured. What can I do?

Log-In to your Google account

Visit the Google API Console and chose one of your recent projects created

Then click on “Services” and activate both: The Drive API and the Drive SDK

This should solve the issue and you should be able to connect the Plugin with your Google Drive

Activate Google Drive SDK and API

The admin bar shows ‘Currently syncing..’ all the time. What’s wrong?

I will describe what’s going on with the plugin for you. The plugin set’s a flag in the WordPress database that shows if the plugin is currently syncing with the Google Drive. It will always sync only 3 files at a time (to not slow down your website due to this activity). Between the states of syncing 3 files and then going on to the next 3 files, the plugin will set the above mentioned flag to 0 (which means: currently not syncing).

In some cases it can be that the sync-progress cannot be finished maybe because you’re currently updating WordPress or when the database connection gets lost. In this case the plugin cannot set back the flag (to 0) and the “Currently syncing…” text is displaying all the time.

You can set this back by

a) Disconnect the plugin and connect it again OR

b) by hitting the “Sync local CDN” button manually from the settings page. In this case the flag will be set back after the sync has finished (this is what I did on your website now).

Does the plugin work for intranet sites?

Short answer: no. Your site has to be public available to connect your site with your Google Drive. Otherwise it will not work. An exception is localhost (or using the IP address 127.0.0.1).

Can I delete my files from my main hosting provider once the sync process has finished?

No. Please note that this plugin is a CDN plugin. It does not replace the media library functionality that is included with WordPress.

Why doesn’t it work with Intense Shortcodes plugin?

A users has reported the the Google Drive as CDN Plugin does not work together with the Intense Shortcodes plugin. This is because this plugin seems to use Googles PHP API, too. But you can get both plugins to work. For this do the following:

Deactivate the Intense Shortcodes Plugin for a short time

Activate the Google Drive as CDN Plugin.

Connect the Google Drive as CDN Plugin with your Google Drive.

If it connects successfully you can re-activate the Intense Shortcodes Plugin again.

This has to be done every time you want to connect the Google Drive as CDN Plugin with your Google Drive. In fact: this has to be done just once. Yo have to do it only when you disconnect the plugin.

You can test if you can set a folder to “Public on the web” by visiting the Google Drive Webpage and do the following:

Create a folder by hitting the red button to your left.

Right click on the folder, and hit “Share…” -> “Share”.

In the little window that appears, click on “Change…” beside “Private – Only you can access” (see this image).

Then select “Public on the web” (see this screenshot) and hit the green “Save” button and then the blue “Done” button.

If you see something like this in the sharing window, you have to set the right permission in your Google Apps account (see above).

Does this plugin replace my media library?

Short answer: no.

Long answer: the primary purpose of a CDN is not to deliver all files from one single source. This means you should spread files accross multiple CDN’s (including your own host).
However it’s possible to delivery all files from Google Drive only. For this go to the settings page and enter “1” into the “Only replace every x file”. Then save your settings.

Do I need this plugin if I’m using CloudFlare?

The answer is: No. This is because CloudFlare is offering their own CDN services.