Thibaud Clement
Thibaud Clement

Reputation: 6897

Rails 4: metainspector gem slowing app down

In my Rails 4 app, I am using the metainspector gem to allow users to display meta data from a URL they post to a form.

Since I installed this gem, each time I try to visit the page of my own app where metadata is pulled from another website, load time increases significantly.

The load time increase goes from an imperceptible delay for small and local websites, to almost freezing the app for larger and foreign websites.

To give you an idea, a regular page usually loads under 400 ms: when we pull data with metainspector, it can go beyond a 30,000 ms (I measured these load times with rack-mini-profiler).

I did not find much about similar issues online.

Here is what I am trying to figure out:

  1. Does this sound normal or did I setup something in the wrong way?

  2. Is there a way to speed up load time with metainspector? For instance by caching responses?

  3. If there is no way to speed up load time, should I implement a timeout limit and display an error message?

Upvotes: 0

Views: 125

Answers (1)

jaimeiniesta
jaimeiniesta

Reputation: 156

That is perfectly normal, to be exact it's not metainspector what is slowing your app down, it's the fact that you're requesting external URLs.

You should try to cache the responses using the built-in caching mechanism in metainspector, but also if possible move this to an asynchronous job using a background queue, and save or cache the result.

Upvotes: 1

Related Questions