rob-murray / jekyll-twitter-plugin

A Liquid tag plugin for the Jekyll blogging engine that embeds Tweets, Timelines and more from Twitter API
MIT License
238 stars 30 forks source link

Cache not working #13

Closed Arcnor closed 9 years ago

Arcnor commented 9 years ago

It seems that tweets are always fetched. From my debugging and limited Ruby experience, the problem is the following:

An Oembed instance gets created. It's key is <url>- (note the empty right part). After the tweet is fetched, that key becomes <url>-{id: <id>}. So when we check on the cache, we use one hash, but when we store, the hash changes.

I'm not sure how @params gets modified (unless when calling @client.oembed tweet, @params that modifies them, of course).

At least for my use case, making the key just <url> works, but having the @params as part of the key might have some implications I'm not fully aware of.

rob-murray commented 9 years ago

Good spot. It seems the Twitter gem is inserting the Tweet ID into the hash - I dont think they mean to as it's for their own internal calls.

In the meantime I will fix this end just to pass in a copy.

Thanks for letting me know I had not noticed that. I used @params as part of the key so that if these change then the cached content is invalidated.