karimali831 Posted June 20, 2011 Share Posted June 20, 2011 Hello! It took a while to find out why one of my pages is slow.. it is because of getimagesize() when users link their avatar to a URL and the URL no longer exist, I use getimagesize() function. Is there something else I can to check for a file existent? It must be for any website. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/239941-getimagesize-slow/ Share on other sites More sharing options...
requinix Posted June 21, 2011 Share Posted June 21, 2011 You can do a HEAD request and check the return status. But whatever method you use, if you're checking on every page load then it will be slow. The only way to speed up the process would be to cache the result, but then it won't always be up-to-date. How about storing the image instead of linking to it? Quote Link to comment https://forums.phpfreaks.com/topic/239941-getimagesize-slow/#findComment-1232538 Share on other sites More sharing options...
karimali831 Posted June 21, 2011 Author Share Posted June 21, 2011 I do both methods for flexibility. Are you saying I should enforce uploads to server only? This I am not sure about... Quote Link to comment https://forums.phpfreaks.com/topic/239941-getimagesize-slow/#findComment-1232539 Share on other sites More sharing options...
requinix Posted June 21, 2011 Share Posted June 21, 2011 There's are distinct advantages to storing the images on the server instead of always linking offsite: besides the issue of efficiency, it's more secure. There's always the chance that somebody could write some script on a server that sends one image to certain people (administrators, moderators, etc.) while sending a different image to other people (people they don't like, people they do like (eight equals equals oh tilde and such), etc.) The short version is that you always remain in control of what shows up on your site. What aren't you sure about? Quote Link to comment https://forums.phpfreaks.com/topic/239941-getimagesize-slow/#findComment-1232541 Share on other sites More sharing options...
karimali831 Posted June 21, 2011 Author Share Posted June 21, 2011 There's are distinct advantages to storing the images on the server instead of always linking offsite: besides the issue of efficiency, it's more secure. There's always the chance that somebody could write some script on a server that sends one image to certain people (administrators, moderators, etc.) while sending a different image to other people (people they don't like, people they do like (eight equals equals oh tilde and such), etc.) The short version is that you always remain in control of what shows up on your site. What aren't you sure about? I have hundreds with off site URLs with many of the links no longer exist so it looks really messy when I specifying an img tag with invalid source. Quote Link to comment https://forums.phpfreaks.com/topic/239941-getimagesize-slow/#findComment-1232569 Share on other sites More sharing options...
requinix Posted June 21, 2011 Share Posted June 21, 2011 I'm confused. What are these images for? Who is uploading them? Quote Link to comment https://forums.phpfreaks.com/topic/239941-getimagesize-slow/#findComment-1232992 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.