Coder Social home page Coder Social logo

prerender-mongodb-cache's Introduction

prerender-mongodb-cache

Prerender plugin for MongoDB caching, to be used with the prerender node application from https://github.com/prerender/prerender.

How it works

This plugin will store all prerendered pages into a MongoDB instance. There is currently no expiration functionality, which means that once a page is stored, future requests for prerendering a page will always be served from from the database cache if it's available and the page caches are never updated.

To get a fresh cache, you will have to delete the cache in the MongoDB instance manually or from another process.

How to use

In your local prerender project run:

$ npm install prerender-mongodb-cache --save

Then in the server.js that initializes the prerender:

server.use(require('prerender-mongodb-cache'));

Configuration

By default it will connect to your MongoDB instance running on localhost and use the prerender collection. You can overwrite this by setting the MONGOLAB_URI or MONGOHQ_URL environment variables to valid MongoDB connection strings.

This is done to make it work automatically when deployed on Heroku with the MongoDB add-ons.

prerender-mongodb-cache's People

Contributors

adamvr avatar lammertw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

prerender-mongodb-cache's Issues

cache-manager should be in the package.json file?

module.js:340
throw err;
^
Error: Cannot find module 'cache-manager'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/home/col/dev/installionv5/node_modules/prerender-mongodb-cache/lib/mongoCache.js:14:21)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)

Update NPM package to latest

I've noticed that v0.0.2 which comes as latest from NPM still uses driver version ~1.3.23 so it doesn't work with MongoDB instances running v3.x because of the new auth mechanism

There is already a commit with the latest MongoDB driver in package.json 91ffe9f

If you could please upload this new version to NPM it would be great! Thanks ✌️

Cannot read property 'url' of undefined

Hey there,
i just added prerender-mongodb-cache to my application and all i get is a Cannot read property 'url' of undefined. Can someone help me?

these are my dependencies...
"dependencies": {
"lodash": "~2.4.0",
"cache-manager": "0.2.0",
"aws-sdk": "~1.13.0",
"phantom": "~0.5.7",
"phantomjs": "~1.9.7-1",
"prerender-mongodb-cache": "0.0.1"
},

thanks a lot!!
kind regard, patrick

Prerender collection or pages?

The docs state it uses the collection "prerender" but it seems to be using "pages"?

database.collection('pages' ...

What should it be?

TypeError: Cannot call method 'collection' of undefined

Randomly occurs:

/var/www/prerender/node_modules/prerender-mongodb-cache/lib/mongoCache.js:46                                                                                                                           │······························································
        database.collection('pages', function(err, collection) {                                                                                                                                       │······························································
                 ^                                                                                                                                                                                     │······························································
TypeError: Cannot call method 'collection' of undefined                                                                                                                                                │······························································
    at Object.mongo_cache.get (/var/www/prerender/node_modules/prerender-mongodb-cache/lib/mongoCache.js:46:18)                                                                                        │······························································
    at Object.module.exports.beforePhantomRequest (/var/www/prerender/node_modules/prerender-mongodb-cache/lib/mongoCache.js:28:20)                                                                    │······························································
    at next (/var/www/prerender/lib/server.js:62:20)                                                                                                                                                   │······························································
    at next (/var/www/prerender/lib/server.js:64:13)                                                                                                                                                   │······························································
    at next (/var/www/prerender/lib/server.js:64:13)                                                                                                                                                   │······························································
    at Object.module.exports.beforePhantomRequest (/var/www/prerender/lib/plugins/blacklist.js:13:13)                                                                                                  │······························································
    at next (/var/www/prerender/lib/server.js:62:20)                                                                                                                                                   │······························································
    at Object.server._pluginEvent (/var/www/prerender/lib/server.js:69:5)                                                                                                                              │······························································
    at Object.server.onRequest (/var/www/prerender/lib/server.js:129:10)                                                                                                                               │······························································
    at Server.wrapper (/var/www/prerender/node_modules/lodash/index.js:3057:19) 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.