Chrome will not display current image / really weird - php

Just 30 mins ago I ran into a really unexpected problem (which as a matter of fact happened to me for the 1st time in my life, and in the 10 years of coding websites).
On a particular page from my admin module, few images reverted to their old state, the exact way they were few days ago. Which means I changed them yesterday, and now they all look like they were before.
It gets more weird. I logged in with Filezilla, and deleted the images. They still appear, with the way they looked 3 days ago, before I changed them.
If I go to the URL of the image it still displays the old images. If I look locally in my Windows folder they are the new version, upload them again, still the browser displays the old version.
I erased the cache in Chrome, even restarted the computer thinking there is something to do with Chrome or something, i really ran out of options. Firefox displays the same, the old images (even if i uploaded the new version of images).
I tried with CPanel FTP manager and...surprise...if i look at an image, it's the good version of images (the new one!). But all browsers fail to see the image.
Also as a keypoint, if I erase the image with ftp, the browser still sees it (SHIFT + f5, still it sees it, so it's not from cache). ?!?!
ANy pointing to the problem is really appreciate. Cheers

Sounds like your hosting provider has a reverse proxy that caches requests for images. One way to overcome the problem is to add something to the URL, perhaps a request parameter, that makes the proxy think that the request is not for the same image.
For example, http://www.example.com/yourimage.png?date=2012-10-25

Sounds like the hosting provider is screwing you over, so I'd say step one is to dump them and move elsewhere...
But if Joni's suggestion doesn't work, you can build your image dynamically on the server, like:
<img src="imageHandler.php?image=myimage.png" />
Your imageHandler.php code would need to read the bytes of the image, and build the HTTP response manually and pass the image bytes back. Not sure what that would look like in PHP, but it shouldn't be more than a few lines of code.
This is a terrible solution, since it would require a ton of processing and disk access for a trivial task like pulling images, but I'd expect that it would at least work.

it's the first time i answer my own question cause it was related to external factors.
yes, problem was fixed, it was actually the guys at tech. dept. at the ISP i have the files hosted, the virtual hosts config file for my domain xxx.net was ..misconfigured.
cheers all, problem is fixed

Related

Wordpress Divi updates don't save

I'm a bit of an amateur so I'm sure I've missed something.
I'm running Divi on Wordpress. When i go to update a page, I get the "Your updates couldn't be saved" error. My Wordpress site, as well as it's CPanel, also are loading unusually slowly, which I think is related to the issue. After working on this for a bit, both my site and it's CPanel will fail to load, giving me a "can't establish a secure connection to the server" error. The third symptom, which I can't make heads nor tails of, when I click "update" in the page editor, my browser will often (but not always) launch another tab/pop-up either displaying a preview of the edits or the "pages" page on the WP admin side. All of these issues are new (although I've had similar loading speed issues in the past with this site).
Thinking it may be an overload on my server (which happened due to an attack a few months ago), I let it sit for a few days with no luck. Then, thinking it may be a caching issue on my end, I changed my DNS servers, cleared my browser cache, tried private browsing, used my phone, used different wifi and cellular networks. All to no avail. I briefly had slight luck using my phone as a hotspot, but it only temporarily improved the loading speeds.
I also tried disabling plugins. I made sure everything was up to date. No help.
I went into my wp-config.php file and increased the memory limit to 128M and the WP-max memory limit to 256M. This helped briefly–I could update and save one page but when I tried to change the next, I was back to base 1. I've also increased the memory limits in my .htaccess file. I don't have access to my PHP.init file (there are often delays reaching my host so I'm trying to avoid relying on them when possible).
My last guess (which I have yet to implement) is to update my PHP. That said, I'm running 7.3.6 and had no issue updating the site a few days ago so I'm not sure that's the problem, unless divi's newest update has compatibility issues with 7.3 versions of PHP...
Any further ideas would be greatly appreciated! I'm partway through a cosmetic update (which, I know should be done on a staging site but sometimes best practices are best learnt through mistakes like this) so my site looks somewhat half-finished. That is, I'm anxious to be able to edit it again.
Many thanks in advance
Whenever you try to save something, Divi will make a request through admin-ajax.php, it often happens that a security firewall detects that as a threat (which is obviously not), thus giving you the failed save message. Can you ask you host to check the rules that are triggered and whitelist that action? It can also come from plugins like Wordfence, make sure to whitelist it there too.
You can also attach that layout as JSON here, I can test it on my own server and if I can save changes, we should be on the right path.

Broken image links causing high load on server. Symfony2/Apache

I have a website built in Symfony 2.8 running on Apache on Ubuntu Server. I had some broken image links on the website, and whenever somebody went to the offending page, it would peg out both the processor and memory, and the browser would continue to try and fetch the missing assets for 60 seconds plus.
I've fixed the missing images, but is there something I can do on the server end to quit searching for missing assets when they're clearly not there?
The way it stands now it would be very easy for an attacker to simply demand content from my website that isn't there, and bring my server to it's knees.
--Edit--
What I'm wondering if there is a way to stop my server from taking a resource hit if somebody tries to access a path/file that's non-existent directly. i.e. if they went directly to example.com/images/non-existent.jpg. Currently on my server my CPU will spike to 100% on one core and RAM usage will slowly climb until the request times out somewhere around 1 min. Just a few more requests like that would use all of my resources.
--Edit 2--
I have discovered since I posted this, that this isn't just limited to images. Any path that should return a 404 error is behaving the same. ie example.com/this/is/not/a/real/path will just hang, and finally time out.
Check if the file exsists before including it in your HTML
if(file_exists('img.jpg')){
// your code for inserting the image into the HTML
}
http://php.net/manual/en/function.file-exists.php

Check the cause of slow loading time among different server

A e-shop has developed using perstashop and put to the three server:
the first 2 is amazon, should be same setting
Server 1:
http://be-pure.com/en/women/3-slim-y-tank.html
Server 2:
http://52.77.216.83/en/women/3-slim-y-tank.html
the last one is just local hosting
Server 3:
http://internal001.zizsoft.com/be_pure/en/women/3-slim-y-tank.html
The problem is server 1 loading very slow compare to the other two server, but the performance should be the best among 3.
It looks as if server 1 hasn't cache the files
but in fact, all of them has
turn on smarty cache, using file system , with recomplie when modify
and
turn on the file system cache
Given that the code and server setting are the same, both 2 amazon server is same setting, and localhost one is other server, however it should be slower than server 1
1) How to debug/ check whether the file is using cache already?
(the cache file locate in cache/smarty and cache/cachefs in server)
2) And what takes the long load time for server 1? Just consider it as an PHP site, any ways to check why it is slow?
Thanks a lot for helping
Refer to the comments - I misinterpreted the data I was looking at earlier. It appears the server can only handle maybe 5-10 requests at a time so things get blocked until the other things are done loading. You likely just need to update your web server's configuration to handle more requests.
There is also a lot of JS data in the file. It is 318KB just to load the page and it has to do many requests to get JS/CSS files before it even gets to any of the HTML. So it is 318KB + all the external JS/CSS it needs to fetch (wow!). That's like 4MB of stuff just to load a page.
Check the modify timestamp on the files generated by your caching system to verify that caching is working.
Edit:
Since there is now a bounty out - please review the comment discussion we had. There is an issue where a traceroute doesn't make it to the server destination and I suspect that is related to the slowness but that type of network issue is over my head.
I am giving answer of your 2nd question.
I dont't know the exact problem of slow loading. but We had faced same issue in one of our projects in last month. Server was amazon.
One of our Instance was very slow. We had tried many solutions but none of them were working. Then We have found a solution which looks very unfair but it Worked for us.
We had Just restarted the slow Instance and We got success.
I hope this solution will work for u also.
All the Best :)
Answer to question 1:
You can use chromes developer tool, F12, and then network tab. It will show you all the files being downloaded, in the size column you can find if it's being loaded from cache or not.
Answer to question 2:
You can use chrome's YSlow plugin. it will help you a lot, but is obvious about your site you have too many files; css, js and lots of images; try to merge your css and js files and use image map for your images.
Hope you can solve your problem
No body can clear answer what is problem with servers. But you can find it with profiling. If you have budget i highly recommend to you buy a profiling tool "Tideways.io", "Blackfire" or "New Relic". I used New Relic, and it really help full to find bottlenecks. If you don't have budget to get a profiling tool you can use php profiling extension Xdebug. It is help full too, but reading profiling output of xdebug can be a bit difficult. But it's setup is really easy, and you can do partial profiling ( you can profile url which you want) with "xdebug profile trigger" instead profiling all requests.
Use this google solid tool to get insight about your page performance.
https://developers.google.com/speed/pagespeed/insights/?url=http%3A%2F%2Fbe-pure.com%2Fen%2Fwomen%2F3-slim-y-tank.html.
Also check if server1 is matching server2 configuration.
This tools shows me lots of suggestions for improvements for your website.

Images Fail to Load, net::ERR_CONTENT_LENGTH_MISMATCH

Problem
When you load up a page on my site, often times one (or several) images (jpg files that I have saved from Lightroom and/or Photoshop) will not appear. It instead looks like a broken link (ALT description appears) but no image. Hard reload of the browser solves problem (e.g. all images load properly after a hard reload).
Error Message
Chrome displays an "ERR_CONTENT_LENGTH_MISMATCH" warning for all images it does not load. (Sometimes the image will flash quickly before going to what looks like a dead image)
Setup
Running latest version of Wordpress (4.2.2) on a Shared Host. Site is SSL (https) if that matters. Images are located in an image upload folder (nothing complex like Imagemagick, etc) on the host.
My Troubleshooting
I have replicated the issue from multiple locations using various ISPs on various machines (both Mac & PC) and with various browsers (Chrome & Safari) some of which are not using any ad-blockers.
What I've tried is the following:
I asked the host if there was an issue on the server side. They claim no.
I've tried resetting the functions.php file. No impact.
I've disabled all plug-ins. No impact.
I've hardkeyed in the meta charset as UTF-8. No impact.
Checked if I'm using Gzip. I am not.
Enabled Wordpress Cache plugin. No impact.
Cleared .htaccess of all non-necessary redirects & commands. No
impact.
Replaced wp-admin and wp-includes folders from fresh install. No
impact.
Deleted Wordpress & Reinstalled from a Backup. No dice.
I've put source code from pages that have this issue into a test.html file and the images seem to load up fine doing that.
My Thoughts & Questions
The images are 100-200kb each and sometimes there are a fair amount of them on the page. Is something timing out and then once I hard reload, everything show up because the timeout isn't tripped? That is the best random guess I can gather without understanding the issue perfectly.
Any ideas of things I can try? Should I delete the whole database and start again? Everything I know about computers is self-taught and server issues are not a strong point for me. Even if you don't know what it might be, could someone explain what a content length mismatch is in general terms?
Thanks much!
When you request data from a web server, it responds first with some information about the data (HTTP headers) and then with the data. One of these pieces of information, an HTTP header, is called Content-Length. It tells the client how much data it should expect to receive from the server. When your browser gets an image, the server's response (very simplified looks like)
Content-Length: 100000
< the image, 100000 bytes of data >
The client knows the request is complete when it has received the amount of data told by Content-Length. Until it receives in this case 100KB (100000 bytes), it considers the image, for example, to not be done loading.
If the server breaks the request before the client receives the data from the server, or if the client receives more data than it received, the client will throw some sort of error and assume the data to be corrupted/unusable and dispose of it. How this is handled can vary between browsers.
How did you upload the images to your website? Myself, I have encountered this problem in a situation where the file's supposed size was stored in the database, and this was used to set the Content-Length header. The file size in the DB wasn't correct for the file. HOWEVER, I know that WordPress does not store file sizes in the database; media uploads are simply represented by a URL.
This could also happen if the web server runs out of resources and can no longer fulfill your requests; you said you had lots of images per page. If you are on a really lousy shared hosting plan, it may be the case that the host imposes limits, or that the server simply can't handle the traffic of all the sites it hosts.
I wanted to circle back on this in case someone else is experiencing this problem. It appears that there is some type of glitch between HTTPS and image retrieval that was causing the problem. While I don't understand WHY that is, I converted my site from SSL/HTTPS to simple HTTP (which I was able to do as it doesn't require encryption) and it appears all images load as they should.
If someone understands the "why", I'd love to understand what the issue actually is. Luckily, I was able to come up with workaround. So, while this doesn't answer my question, it does provide context of what is causing the problem and my common sense workaround.
You might see this problem with a shared hosting service. Free bandwidth is like free speech, not free beer. Resource outage policies are invoked during traffic spikes.
A distributed system architecture solves this by inserting a front-end CDN tier (eg. CloudFlare). CDNs cache your static resources and can vastly reduce the load on your host. In fact, for completely static sites the host can be shut down.
There are other advantages to CDNs, like attack detection, free SSL (not beer) and overall improved performance and security compared to shared hosting alone.
Many CDNs are free (as in speech). You could also upgrade to private hosting, but $ and you still might want a front-end tier.

Apache is lagging or something else is bad

I have a website. It's my first website with Zend Framework but I think it's written good. Generatiom time is about 0.9s now. I'll do it something like 0.2 but leave it now. When you press any link on the website it tooks about 1,5-2s before web browser is loading page. Then it tooks 0.15s to show it. So if execution time is 0.9 where are the other 1.1s? Ping is about 13ms. Website address is http://zgarnijlicke.pl
Edit:
Strange. Second domain, http://lottek.eu, is working good. Look at http://lottek.eu/picostreamer. It isn't lagging like the zgarnijlicke.pl domain.
Edit 2:
There is a problem with Zend-Framework. I setted up action without rendering view (layout disabled too) and it's working as fast as server can do it. I'll make new question for it.
Here's a webpagetest.org report for your site: http://www.webpagetest.org/result/100721_1P0Y/
If you view the waterfall graph for the first view, you'll see that the browser gets your HTML source at around the 1.2 second mark, and is first able to render your page at just after 4 seconds. What happens in between those two is downloading of your three javascript files and two CSS files. So, this is where you want to start. Some suggestions:
Consider using a free CDN for jquery.js insteading of serving it from your server, e.g. Google's: http://code.google.com/apis/ajaxlibs/ . This way, users are more likely to already have it cached, Google will serve it from a location geographically closer to the user, and (I think) in compressed format.
For jquery.corner.js and jquery.media.js, consider merging them into one file and serving them compressed (the Apache module mod_deflate makes this very easy to do)
Same for your CSS files - consider merging them into one file and serving them compressed.
Those will give you some quick wins. However there are other things you can improve:
Add width and height attributes to your image tags. Without these, some browsers will halt rendering while they download the images so that they know how much space they'll occupy. None of your image tags have these attributes.
Make sure you're using the right image format for the job. Your banner.png image is over 300k which is far too large. I converted this to a JPEG image (80% quality) and it was 30k.
As for the execution time, 0.9 seconds seems quite high. Are you using APC or similar? Is the page doing any heavy database work?
Try putting some timer code in your php that measures the length of time it takes to generate the page content. This way you can confirm or rule out server problems.
You might also use network tools like ping and traceroute to see if your problem is caused by network latency.
A quick test with wget here gets an overall execution time of 1.5s to transfer one of the pages, with an actual download time of 0.2 seconds, so 1.3s of overhead. The pause occurs before the transfer starts, so that's a server-side problem.
Is that site on a virtual server? It's possible that if the underlying physical server is heavily loaded, your image could be getting swapped out or otherwise CPU-starved and takes ~1 second to become responsive again.
Perhaps it's an internal resource thing - are you connecting to a DB, especially a remote one? Even if some or most of the pages aren't DB-driven, the overhead of connecting to a DB could be causing this slowdown. And then gets swapped/delayed again as there's little further activity to keep the image active.
It could even be something as silly as Apache being configured with 'IdentityCheck' on, though unlikely, as this would slow down all requests. I'm not seeing any slowdown on the requests for .css/.js files from your server when viewed from HTTPFox. Interestingly, requesting the .css/.js via wget returns a '500 Internal Server Error'.
I found it. It's problem with ZF because when I did hello.php page with code like that:
hello world
Without any < ?php ?> script took 0.4s to complete.

Categories