生成用作签名的个人图像
我想制作一个个人图像,显示用户的最后 3 个项目(这样他可以用作论坛签名,但它不能是像 user?id=1 这样的动态图像,因为大多数论坛都会阻止这样做) 我打算使用 GD,这不是问题,但是: - 要在插入数据时更新图像,我是否只是在插入脚本中放置“更新图像”还是有更好的方法?我想在插入后最多 5~10 分钟内更新图像
- 如果 500 个用户正在使用此服务,是否会要求服务器提供太多资源?不是带宽,我的意思是创建图像 每个用户通常每周更新他的项目 3 次或更多次,更新次数不会太多,
- 因为它只更新用户操作,不涉及缓存,对吧?
谢谢
i want to make a personal image, that shows the last 3 items from the user (so he can use as forum signature, but it cant be a dynamic image like user?id=1 because most forums blocks that)
im planning to use GD, thats not a problem but:
- to update the image as data is inserted, do i just put a "update image" in the insert script or there's a better way? i want to update the image in a max time of 5~10 minutes from the insert
-if 500 users are using this service, is that going to demand way too much resources from the server? not bandwith, i mean to create the image
each user normally updates his items 3 or more times a week, not that much
- since its only update on user actions, cache is not envolved, right?
thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这不会是性能问题(估计每周负载 - 1500 张图像 - 可以在几秒钟内生成)。您还可以仅在请求时生成图像并将其缓存...
您可以通过使用不带查询字符串的干净网址来解决论坛签名问题中的动态网址:
http://www.my.site/my/image/123
mod_alias 可以将其内部重定向到图像生成器...
it wouldn't be a performance issue (the estimated weekly load - 1500 images - can be generated in a few seconds). you could also generate the image only when it's requested and cache it...
you could get around the dynamic url in the forum signature problem, by using a clean url without a querystring:
http://www.my.site/my/image/123
mod_alias can redirect that internally to the image generator...
如果您不希望用户在上传时必须等待脚本更新其签名,则必须在数据库中为该用户设置一个标志,然后每 5 分钟运行一个 cronjob 或一些此类自动化脚本左右。 cronjob 可以查询数据库以查看哪些用户需要更新,然后执行更新。
如果图像名称保持不变(例如“user_15_sig.jpg”),则图像可能会被浏览器缓存。因此,即使您更新了服务器上的图像,缓存该图像的用户也会看到旧的图像。您可以通过在图像名称中附加一个变量(又名“user_15_sig.jpg?temp=123”)来解决这个问题。但是既然您说过您想避免图像具有任何动态上下文(即使它不会动态生成) ),您必须以某种方式更新图像名称。一种方法是在数据库中有一个字段来保存该用户图像上次更新的时间戳,然后在保存更新版本时将时间戳附加到图像名称。 (又名“user_15_sig_1234567.jpg”,其中 1234567 是时间戳。
If you don't want the user to have to wait for the script to update his sig when he uploads, you will have to set a flag in the db for that user, then have a cronjob or some such automated script running every 5 minutes or so. The cronjob can query the DB to see which users need updating, then perform the update.
If you have the image name stay the same (aka "user_15_sig.jpg" for example), the image may be cached by the browser. SO even though you updated the image on your server, users that have that image cached will see the old one. You can get around that by appending a variable to the image name (aka "user_15_sig.jpg?temp=123). BUT since you said you wanted to avoid having any dynamic context to the image (even though it wouldn't be dynamically generated), you would have to make the image name update somehow. One way would be to have a field in the DB that holds the timestamp of last update on that user's image, then append the timestamp to the image name when you save the updated version (aka "user_15_sig_1234567.jpg" where 1234567 is the timetamp.