Jump to content

godius

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

godius's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hey guys, i have a javascript function which fetches data from a PHP file, then posts it back to a DIV. This works great, in all browsers. But now I wanted to get data into the DIV in realtime, so it doesnt have to wait for the PHP script to complete all its data, for this I use ReadyState == 3 instead of ReadyState == 4. Now this works great in Firefox, but in IE 8 and Google Chrome it does not want to work. function ajaxDo(user_key,option_id) { var req = null; var user_key = user_key; var option_id = option_id; var link = "/ajax_tools.php?uri=" + user_key + "&o=" + option_id; document.getElementById("tools_output").style.display="block"; document.getElementById("tools_output").innerHTML="Loading data..."; document.getElementById("tools_output_status").style.display="block"; if(window.XMLHttpRequest) req = new XMLHttpRequest(); else if (window.ActiveXObject) req = new ActiveXObject("Msxml2.XMLHTTP"); req.onreadystatechange = function() { if(req.readyState == 3) { document.getElementById("tools_output").innerHTML=req.responseText; } if(req.readyState == 4) { document.getElementById("tools_output_status").style.display="none"; } }; req.open("POST", link, true); req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); req.send(null); } This is the whole function posted above, the part that is playing up is if(req.readyState == 3) { document.getElementById("tools_output").innerHTML=req.responseText; } Its seem Chrome and IE8 do not know readyState == 3, only 4. What can I do about this?
  2. Corbin you da man!! works like a charm.
  3. Seems my code is still buggy. The regex problem i have posted elsewhere: http://www.phpfreaks.com/forums/index.php/topic,270675.0.html
  4. Hi guys, im trying to make a .htaccess file with mod_rewrite. My goal is to forward all 4 character filenames that are .jpg, to /pic.php?i=filenamehere. RewriteEngine On RewriteRule ^(.*)\.jpg$ /pic.php?i=$1 That works, but it forwards ALL jpgs on my server, but it should only fake the links that are straight on my domain root. http://domain.com/ABCD.jpg - this should be linked to http://domain.com/pic.php?i=ABCD.jpg ABCD.jpg = in the root directory, and is 4 characters. All other .jpgs should be ignored by this rewrite. Can anyone please help me get the right rewriterule? Thanks so much!
  5. Never mind... i found it Options Indexes FollowSymLinks MultiViews All php_flag register_globals on RewriteEngine on RewriteRule RZVB(.*)\.jpg$ /index.php?i=$1 Thanks for all your help guys!! caching works perfect now.
  6. Ok thanks, at least i know what im doing wrong now So i wrote a little something, but it does not work. .htaccess Options Indexes FollowSymLinks MultiViews All php_flag register_globals on RewriteEngine On RewriteRule ^/([A-Z]+)\.jpg$ /pic.php?id=$1 [PT,L] Shows.. Not Found The requested URL /RZVB.jpg was not found on this server. http://img.cx/pic.php?i=RZVB does show the image, but maybe my mod_rewrite code isnt correct. Does anybody know?
  7. No im not. Dont think that is possible with the REAL path vs FAKE path. http://img.cx/RZVB.jpg = FAKE path http://img.cx/uploads/full/20090922/RZVB.jpg = REAL path The '20090922' a directory with the date of the day the image was uploaded. This is done to prevent 1 directory from getting overloaded with images. Or am i wrong and is it possible with mod_rewrite? my current .htaccess Options Indexes FollowSymLinks MultiViews All php_flag register_globals on ErrorDocument 404 /index.php <FilesMatch "\.(jpg|jpeg|gif|ico|png)$"> Header set Cache-Control "max-age=604800, public" </FilesMatch>
  8. Its not working yet, its probably because the image is not found on that location... the header is 404, as the real image is hosted elsewhere. http://img.cx/RZVB.jpg = Date: Fri, 25 Sep 2009 08:36:50 GMT Server: Apache/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.2.8 X-Powered-By: PHP/5.2.8 Pragma: public Cache-Control: max-age=604800, public Content-Length: 3429601 Keep-Alive: timeout=15, max=97 Connection: Keep-Alive Content-Type: image/jpeg 404 Not Found http://img.cx/uploads/full/20090922/RZVB.jpg = Date: Fri, 25 Sep 2009 08:33:37 GMT Server: Apache/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.2.8 Last-Modified: Tue, 22 Sep 2009 10:50:09 GMT Etag: "2279be-3454e1-474285ca9fa40" Accept-Ranges: bytes Content-Length: 3429601 Cache-Control: max-age=604800, public Content-Type: image/jpeg 200 OK Cache probably does not work because of the 404 error, even though it does display the image correctly. But does not cache it... Any idea what i can do now to get it working?
  9. I have tried that before, was no go. Ive have added them to my .htaccess files again. It does not work. Caching DOES work when I link to the full path of the image, eg: http://img.cx/uploads/full/20090922/RZVB.jpg But when i get the image via my index.php script, it always completely reloads the image. Any ideas?
  10. Hi guys, i run a small image hosting site, and i have a problem with caching my images. I want to make the URL as short as possible, so i have a script which fakes the location of the images. http://img.cx/RZVB.jpg is an image for example, but really the image is in a different location /uploads/blabla/secret/bla/RZVB.jpg (for example). My index.php script fakes this location, which works great, but browsers will not cache the image now, which is annoying for the users. Everytime I re-load an image, it gets all the data fresh from the server, instead of from the browsers cache. In my index.php i read out the image like this. $image_location = 'uploads/full/'.$result->image_folder.'/'.$image_id.'.'.$image_type.''; $expires = 60*60*24*14; header("Pragma: public"); header("Cache-Control: maxage=".$expires); header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT'); header('Content-Length: '.filesize($image_location).''); header('Content-Type: image/'.$image_mime.''); readfile($image_location); exit; I have also tried caching .jpg/.gif/.png files via .htaccess file, but that also did not work. Im running php 5.2.8, on Cent OS 5, and apache 2. Please how do I enable caching for this image forwarding that im doing?
  11. Hello im running a quad core 8GB machine with fast scsi drives with 64bit centos 5. Now on that site i run a site that get about 750.000 unique visitors, and the site uses ajax intensively. every pageview uses about 15 ajax http requests. I used to run my site on apache, but because of the insanely high load i decided to move to nginx. I have setup nginx with php-fpm, and it is running quite good, only when it gets really busy (around 25 pageviews per second), i sometimes notice that i have to wait a few seconds before the server sends a response. This only happens when its busy, so i think ive hit some kind of limit in nginx. It is probably possible to resolve this by changing a certain value somewhere. The server load is always low, around 1. Below i have posted some of the settings i have already modified. [b]nginx.conf[/b] events { worker_connections 6000; } worker_processes 12; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 10; gzip on; gzip_comp_level 2; gzip_proxied any; gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript; [b]php-fpm.conf[/b] <value name="max_children">3000</value> <value name="StartServers">200</value> <value name="MinSpareServers">600</value> <value name="MaxSpareServers">2000</value> <value name="request_terminate_timeout">10s</value> before on apache my site used to get busier because it was able to handle up to 35 pageviews per second, now i never see it go over 25, because i think nginx can not handle more with my current setup. Please advice how to tune/optimize/improve my settings. Kind regards, Godius
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.