FAQ

This is the FAQ page for our Google Drive as CDN WordPress Plugin.

Google announced that web hosting in Google Drive will be deprecated. You can continue to use this feature (and this plugin) until August 31st, 2016, but after that, googledrive.com/host/ID will no longer work. Note that due to this fact, this plugin will no longer be supported and further developed after 01.09.2016.

How does the Google Drive as WordPress CDN Plugin work exactly?

The plugin works like this:

  1. If anyone visits a page of your website, the plugin searches for files that can be uploaded to Google Drive.
  2. If the file is not yet uploaded to Google Drive the plugin will put it down into the cache-database for a later upload.
  3. 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.
  4. Synced files can then be served directly from your Google Drive.
  5. You can manually start syncing the files that have been written to the cache-database by clicking the “Sync local CDN”-button.
  6. From time to time every single file gets located and uploaded to Google Drive. Because of this process the speed of your website should improve continuously.

Please note:

  1. It is recommended to use a “caching plugin” like WP-Super-Cache to significantly improve page load time further.
  2. You can start sync your local media library to Google Drive using the “Sync my media library now”-button. Depending on the size of your media library this will take some time.

How do I install the plugin?

  1. Upload the google-drive-cdn folder to the /wp-content/plugins/ directory.
  2. Activate the plugin through the „Plugins“ menu in WordPress.
  3. Configure the plugin by going to the „Google Drive CDN“ menu that appears in your settings menu.

Ho do I configure the plugin?

Step 1: Install the plugin

Install the plugin according to the FAQ (see question 1).

Step 2: Setting up the plugin in Googles Cloud Console

Important: Googles API is now called Google Cloud Console. If you are logged in and see the old API console Google will show a link that lets you switch to the new Cloud Console.

    1. After activating the plugin, go to the “Google Drive CDN“ menu that appears in your settings menu.
    2. You need a Google account. You do not have a Google account? Click here to create one: https://www.google.com/accounts/NewAccount
    3. Create an API project in the Google Cloud Console (former Google API Console) by following this link: https://cloud.google.com/console
    4. Click the “Create Project” button and type in a name (ex. “WordPress to Google Drive”) and a project ID (like “wp-to-gd” – should be unique)
    5. (Optional: If you want to host your files only on EU data centers, click the “Show advanced options…” link and choose the appropriate option from the dropdown.)
    6. Click the “Create” button. It will take some time till the project appears in the console.
    7. If done click “APIs & auth” -> “APIs”. Search for “Drive API” and click it. Then activate the “Drive API” by clicking the blue “Enable API” button (see screenshot).
    8. Then click the “APIs & auth” -> “Credentials” link. (Please note that in an earlier version of the Cloud Console you had to register a new app in this step).
    9. Click the button which says “Add credentials” and choose “OAuth 2.0 client ID”.
    10. Before you can choose from an application type you have to set-up the consent screen. For this click the button that says “Configure consent screen” (see screenshot).
    11. In the “OAuth consent screen” window, choose your E-Mail address and type-in a product name (like “WordPress to GoogleDrive”). All other options are optional. (See screenshot).
    12. Click “Save”.
    13. Now you’re back on the “Create Client ID” screen. Choose “Web application” from the “Application type” list.
    14. In the field “Authorized Javascript origins” enter your website URL (ex. https://wp-buddy.com)
    15. In the “Authorized redirect URI” field enter http://YOUR_URL/wp-admin/options-general.php?page=wpbgdc. Where YOUR_URL is the URL to your homepage (ex. wp-buddy.com).
    16. Then click “Create.
    17. Now an overlay give you the information you need (OAuth client ID and Client Secret). Copy and Paste the information into the field on the settings page of the plugin.
    18. If you don’t see the overlay window, do the following:
    19. Click onto the Client ID that was created seconds ago (see screenshot).
    20. In the next window you will see the information you need (Client ID and Client Secret), see screenshot.
    21. Enter the Client ID and the Client Secret on the settings page of the plugin.
Google Cloud Console
Google Cloud Console

Step 3: Grant permission to Google Drive

  1. After the above steps you will see a big blue button which says “Grant writing permissions to your Google Drive”. Click on it.
  2. You will be redirected to a Google-hosted page. You will be asked if you really want to grant access.
  3. Click on the blue button which says “Allow access”.
  4. You will be returned to the plugins settings page.
  5. That’s it. Your Google Drive is not linked with your WordPress installation.

Step 4: Changes settings

  • Only upload every X file
    This 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?

  1. If anyone visits a page of your website, the plugin searches for files that can be uploaded to Google Drive.
  2. If the file is not yet uploaded to Google Drive the plugin will put it down into the cache-database for a later upload.
  3. 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.
  4. 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?

  1. If anyone visits a page of your website, the plugin searches for files that can be uploaded to Google Drive.
  2. If the file is not yet uploaded to Google Drive the plugin will put it down into the cache-database for a later upload.
  3. 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.
  4. 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.

Screenshot from the API-Console
Screenshot from the API-Console

Regarding the traffic / bandwidth of the download of files: A Google employee answered this questions on stackoverflow as follows:

“(…) 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 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:

  1. Open the wp-content/plugins/google-drive-cdn/classes/google-api-php-client/src/config.php file with your favourite text editor
  2. Near line 48 you can find this lines:
  3. Replace these four lines with the following line:
  4. 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.
  5. 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.
  6. 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?

  1. Log-In to your Google account
  2. Visit the Google API Console and chose one of your recent projects created
  3. Then click on “Services” and activate both: The Drive API and the Drive SDK
  4. This should solve the issue and you should be able to connect the Plugin with your Google Drive
Activate Google Drive SDK and API
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:

  1. Deactivate the Intense Shortcodes Plugin for a short time
  2. Activate the Google Drive as CDN Plugin.
  3. Connect the Google Drive as CDN Plugin with your Google Drive.
  4. If it connects successfully you can re-activate the Intense Shortcodes Plugin again.
  5. 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.

Google tells me:  “Error: invalid_client – no support email”. What’s wrong?

Google is missing an E-Mail address. Just follow Step 2 – Setting up the plugin on Googles cloud console again. And don’t miss step 6 and 7 where you have to select your E-Mail address.

Can I use the plugin with my Google Apps account?

Yes, but please make sure that your Google Apps account has the permission to set a Google Drive folder to “Public on the web“. Otherwise you will get a

  • Error calling POST https://www.googleapis.com/drive/v2/files/xxxxxxxx/permissions: (400) Bad Request(wpbgdc: create_folder 2) OR
  • Error calling POST https://www.googleapis.com/drive/v2/files/xxxxxxxx/permissions: (400) Bad Request(wpbgdc: search_folder 1)

error.

To achieve this, go to Google Apps > Drive > Sharing settings (Where can I find this menu?). Then select the following:

  • “Users can share documents outside the organization” AND
  • “Allow users to share outside the domain to people who are not using a Google account” AND
  • “Allow users to publish documents on the web or make them visible to the world as public or unlisted documents”

Read more about this here: https://support.google.com/a/answer/60781

After that, connect the plugin again and it should work as expected.

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.