简体   繁体   English

缓存Facebook / Twitter个人资料图片

[英]Cache facebook/twitter profile image

I want to let the users upload their facebook/twitter profile picture as an avatar. 我想让用户将他们的facebook / twitter个人资料图片上传为头像。 I insert a record with their token/secret in the DB. 我在数据库中插入了带有其令牌/秘密的记录。 I've made a script that gets the user's id and displays the profile image using readfile() but I want to cache this image for 30 minutes. 我制作了一个脚本,该脚本获取用户的ID并使用readfile()显示个人资料图片,但我想将此图片缓存30分钟。 Is this possible with codeigniter? Codeigniter有可能吗?

Although not codeigniter specific.. On a site I created - when the user logs in with facebook, we download the file using something similar to file_get_contents.. we then store our local reference to it along with a MD5 of the image data.. This allows us to easily check whether we need to update our local store when the profile is next requested (this does require the server to re-download from facebook) 虽然不是特定于Codeigniter的。.在我创建的网站上-当用户使用Facebook登录时,我们使用类似于file_get_contents的方式下载文件。.然后,我们将对其的本地引用以及图像数据的MD5存储起来。允许我们轻松地检查下一次请求配置文件时是否需要更新本地商店(这确实需要服务器从facebook重新下载)

In other instances, we store the file size that facebook reports, so that we can do a HTTP HEAD request to check easily if its changed (I realise size doesn't have a direct relationship to the image changing.. however 99.9% of the time its a good indication. 在其他情况下,我们存储facebook报告的文件大小,以便我们可以执行HTTP HEAD请求以轻松检查其是否更改(我知道大小与图像更改没有直接关系。但是,该更改的99.9%时间是一个很好的指示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM