w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Managing Nginx FastCGI cache files
From reading http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_cache_path I would note that cache size and contents are managed through following options to fastcgi_cache_path directive: inactive: "Cached data that are not accessed during the time specified by the inactive parameter get removed from the cache regardless of their freshness. By default, inactive is set to 10 minutes." So I would suppose that with default settings all files that were not accessed within last 10 minutes should be removed; max_size: "The special cache manager process monitors the maximum cache size set by the max_size parameter. When this size is exceeded, it removes the least recently used data.". I would guess that you do not have max_size limit set at all. So with large number of objects

Categories : Nginx

FastCgi vs PHP-FPM using Nginx web server
PHP-FPM is much better than the old FastCGI handling of PHP. As of PHP 5.3.3 PHP-FPM is in core and the old FastCGI implementation isn’t available anymore. My answer was just down voted (after being online for quite some time) and I understand why, so here is a list why PHP-FPM is actually better than the old FastCGI implementation. First of all, it was known for quite some time that the FastCGI implementation is bad in the PHP community. A page that documents that can be found at https://wiki.php.net/ideas/fastcgiwork where it says: php-cgi is not useful in production environment without additional “crutches” (e.g. spawn-fcgi from lighttpd distribution or php-fpm patch). This project assumes integration of such “crutches” and extending php-cgi to support for different prot

Categories : Nginx

Nginx + fastcgi multithreading
The problem is solved. Use FCGX_OpenSocket and umask(0) in order to let socket accept. This will give you real multithreaded application. #include <pthread.h> #include <sys/types.h> #include <stdio.h> #include "fcgi_config.h" #include "fcgiapp.h" #define THREAD_COUNT 8 #define SOCKET_PATH "/var/run/myfcgiserver.sock" // your unix socket file static int socketId; static void *doit(void *a) { int rc, i; FCGX_Request request; char *server_name; if(FCGX_InitRequest(&request, socketId, 0) != 0) { printf("Can not init request "); return NULL; } printf("Request is inited "); for(;;) { static pthread_mutex_t accept_mutex = PTHREAD_MUTEX_INITIALIZER; printf("Try to accept new requ

Categories : C++

Nginx + FastCGI + C throws 502 Bad Gateway
Its look like your php5-fpm is not running om 8000 port as you included in nginx conf fastcgi_pass 127.0.0.1:8000; You can verify your php5-fpm is running on that port by using following commands grep -Hr "8000" /etc/php5/fpm/pool.d For setup php5-fpm on 8000 open following file and change listen to 8000 port vim etc/php5/fpm/pool.d/www.conf now search listen and replace it with following line listen = 127.0.0.1:8000 Save the file and restart php5-fpm

Categories : C

Using Lua in nginx to pass a request to FastCGI
Use the ngx.location.capture() method to perform a subrequest to a predefined location block. Then, from within the location block, perform the external, FastCGI request. Because the subrequest itself isn't actually a network operation, but is performed purely within nginx C-based environment, there's very little overhead. Further, because the FastCGI request and other "proxy_pass"-type requests are event-based, nginx can operate as an efficient intermediary. As an example, you could have the following: location / { access_by_lua ' response = ngx.location.capture("/my-subrequest-handler") if response.status == 404 then return ngx.exit(401) -- can't find/authenticate user, refuse request end ngx.say(response.status) '; # other nginx config stuff here as

Categories : Nginx

My nginx + fastcgi configuration downloads php files instead of executing them
Your php code is being displayed directly because it's not being sent to the php engine, that means the location block is being matched and the php file is being served, but the php file isn't being captured by the php block, so your problem is in the php block. In that block you have 2 fastcgi_pass, one with a port (9000) and the other to a unix socket, you can't have both together, but since you've tagged your question with fastcgi so I'll assume you are using fastcgi, try commenting this line #fastcgi_pass unix:/var/run/php5-fpm.sock;

Categories : Nginx

How to limit max file size for upload in nginx for special location with fastcgi
Is the URI really and exactly http(s)://example.com/account/personal_info/documents/ in your browser? If so, be more specific in your configuration to make sure nginx applies the correct location block. location = /account/personal_info/documents/ { # ... }

Categories : Nginx

Why Nginx cuts long responses from Node.js?
Have you tried with proxy_buffering on? Maybe node is taking to long to answer and nginx stops reading. Try increasing the proxy_read_timeout (default is 60s).

Categories : Node Js

Best Practice to locally cache web service responses
Check out the LruCache class, or better yet check out the Android Volley framework developed by Google.

Categories : Android

Nginx return file when it's in cache/check if file exists in cache
Ok, maybe not so beautiful solution but upstream can be used with one server makred as down. http { upstream backend-jail { server 0.0.0.0 down; } server { listen 80; underscores_in_headers on; recursive_error_pages on; error_page 597 = @jail; location / { if ($http_x_backend_down = "1") { return 597; } proxy_pass http://lcoalhost:8080; proxy_set_header Host $host; proxy_cache my-cache; proxy_cache_valid 200 302 1h; proxy_cache_valid 404 1m; proxy_cache_key $uri$is_args$args; } location @jail { # dont need to log error about 'no live upstreams' error_log /dev/null crit; # backend-jail always return 502, want 404 to be return

Categories : Caching

How to disable nginx cache
Solved my problem... Installed manually following this steps: http://eksith.wordpress.com/2008/12/08/nginx-php-on-windows/ with pure nginx i could disable cache on nginx.conf

Categories : Caching

How can I optimize this nginx proxy cache configuration?
A nested location is the right way to create locations with regular expressions and it should do the trick for what you want to achieve. location / { proxy_pass http://192.168.12.12:91; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; location ~* .html$ { proxy_cache cache_one; proxy_cache_key $host$uri$is_args$args; proxy_cache_valid any 1m; expires 1m; } } I’m not totally sure if the nested location is really using the options from the outer location block. If it doesn’t (I can’t test this right now) you could create separate files. location / { include proxy.conf; location ~* .html$ {

Categories : Linux

Nginx: Response handling and Reverse Proxy with Cache
Actually, location.capture is not designed to do things you doing, but, if I get you correct (you want to send headers that browser send you to subrequest) you, probably, can hack it around using ngx.ctx + set ;) But I'd say it is a very dirty kludgy way.

Categories : Nginx

How to speed up delivery for static files with nginx? (Cache them in memory?)
Assuming you have enough memory in your system, the css file should be being cached by the operating system. I'd put multi_accept on; in the events section but otherwise your config looks fine. Nginx should be serving your css file gzip'd and quickly. I'd be inclined to test it with another file and also see how it compares with proxying the file from Apache. I have a feeling your problem is not where you think it is.

Categories : Caching

Nginx set separate browser cache expiry for Index pages
Got the answer finally. had to go through the nginx working manual. Handling a request “/” is more complex. It is matched by the prefix location “/” only, therefore, it is handled by this location. Then the index directive tests for the existence of index files according to its parameters and the “root /data/site” directive. If the file /data/site/index.htm exists, then the directive does an internal redirect to “/index.htm”, and nginx searches the locations again as if the request had been sent by a client.. so i had to add one more location to search for my index.htm file location ~* index.(htm|html)$ { expires 1d; root /data/site; index index.html index.htm; }

Categories : Nginx

Where is my nginx being configured? Changing nginx.conf still brings me to the 'Welcome to nginx' page
when you rewrited the nginx.conf in the folder of source code of nginx and installed it firstly, it will be copied to /usr/local/nginx/conf/nginx.conf (without specially modification of the configure in the folder of source code). But when you do this secondly, the nginx.conf in the folder of source code will be copied to /usr/local/nginx/conf/nginx.conf.defualt,and it usually don't work unless you use nginx -c /usr/local/nginx/conf/nginx.conf.defualt to assign its configure file evertime. There is a line NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" in your script above,which indicates the configure file clearly. To handle this, I suggest rewrite /usr/local/nginx/conf/nginx.conf (not the one in the folder of source code) instead.

Categories : Nginx

How do I make my positive integer become negative and stay negative until the end of my action?
If the code works fine when slide = 1, I would suggest removing this: if (slide >= 2) { if (x < 0) { x = -x; } if (y < 0) { y = -y; } checkBoundariesTouching(); } If you need that code to move the boxes back on the screen, you can put the if statements inside a separate method and call that method when you change slides.

Categories : Java

Matching negative and non-negative numbers in perl
Does this meet your needs? /^w+s*-?w+$/ It says match: w+: any number of alphanumeric characters (including underscore) s*: any number of spaces (if you need atleast one space, use s+) -?: optional dash w+: any number of alphanumeric characters (including underscore). If this set of characters can only be numbers, then use d+ instead.

Categories : Regex

Restarting nginx: nginx: [alert] Unable to start the Phusion Passenger watchdog because its executable
Passenger takes what you set in the file nginx.conf by passenger_ruby, for example: passenger_root /home/dev/.rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.5; passenger_ruby /home/dev/.rvm/wrappers/ruby-1.9.3-p448/ruby;

Categories : Ruby

Can a server run Nginx for some sites and Apache Nginx Reverse Proxy for others?
server { server_name example.com; location / { # assuming apache is on port 81 for example proxy_pass http://127.0.0.1:81; # to make apache detect the host header proxy_set_header Host $host; } # if you have assets folders, you can let nginx serve them directly, # instead of passing them to apache location /images { # or /css or /js .. etc try_files $uri =404; } } Note: in the case of assets, sometimes some sites serve assets through rewrites, or even handled by the application it self, you can pass it to apache by adding that in the assets location as a fallback like this location /images { try_files $uri @apache; } location @apache { proxy_pass http://127.0.0.1:81; } In apache you create a virtual host <Virtua

Categories : Apache

How to use FastCGI to send an image
Rather than copying files from the filesystem yourself an echo'ing them back to Apache, why not use something like https://tn123.org/mod_xsendfile/ . All your response includes is standard headers and a special X-Sendfile header. The server module reads the file from the filesystem and returns it to the client.

Categories : Perl

How do I get requestId of FCGI process in Perl using Net::FastCGI?
You wouldn't. There's no sense in using Net::FastCGI when you're already using FCGI. The request ID, if you need it, is available in $request->{id} after calling $request->Accept. It's not clear what you mean by "receives and returns same request IDs" though.

Categories : Perl

PHP Uploading with FastCGI on IIS 7.5 stalling/taking forever
Welp, that was stupid. I just asked around and someone did infact turn on "intrusion prevention" at the router level for the one server that was having issues. Disabling that seems to resolve the problem.

Categories : PHP

Plesk auto update crashes FastCGI support
SElinux? What is permissions on /var/www/cgi-bin/cgi_wrapper/cgi_wrapper? should be -rwxr-xr-x 1 root root 3660 Jun 6 2012 /var/www/cgi-bin/cgi_wrapper/cgi_wrapper What in /var/log/apache2/suexec.log or /var/log/httpd/suexec_log ? Permissions on suexec ? Find all files, check permissions: find / | grep suexec Custom php.ini on domain / custom php settings on domain? Is their is compatible with current PHP version? What happens if run php script in cli mode like: php -c /var/www/vhosts/domain.tld/etc/php.ini /var/www/vhosts/domain.tld/httpdocs/index.php Connection reset by peer: mod_fcgid: error reading data from FastCGI server

Categories : Misc

Random PHP FastCGI / Connection reset by peer / incomplete headers
This issue is generally not just Host specific, it is developer related as well, depending on the configuration. However some hosts are rather strict with FastCGI and will limit your capabilities. It is generally easier to run without using FastCGI and just use mod_php unless you have specific need to use FastCGI in your application. We would need to see your fcgi wrapper (what's in /dev/shm/blackmou-php.fcgi) or .htaccess for FastCGI spawning, to better assist you without knowing which files and the code that is on those files the issue occurs with. Also do your hosts use Apache, LightHttpd, or Nginx (or combination)? At that point I strongly suggest updating to use PHP 5.3.9+ As this can be caused by any number of issues, FastCGI effectively prevents your site/scripts from being attack

Categories : PHP

Using Redis as the Spring cache manager in order to cache custom java objects
You can start by looking at Spring Data Redis, but unlike Spring Data JPA, is doesn't offer repository abstraction, instead using Spring templates with accessor methods specific only to redis. Since Redis does not support relations, you'll have to design and implement these relations by overriding JPA's standard CRUD operations. Here's a great article that details something up your alley... http://www.packtpub.com/article/building-applications-spring-data-redis I am new to Redis and it seems Redis is only able to cache the basic types/structures it knows (strings, hashes, etc.) Redis can store anything; text, json, binary data, it doesn't matter. By default, RedisTemplate (part of Spring Data Redis), uses Java serialization to marshal/unmarshall objects to/from redis, but it uses

Categories : Spring

Amazon Cloudfront Cache-Control: no-cache header has no effect after 24 hours
Verify that the CloudFront distribution's Minimum TTL is set to 0. If it's set to any other value, CloudFront won't respect the no-cache header and will still cache the file for the Minimum TTL. More details about the caching directives can be found here: http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html If this doesn't help, try to debug the actual HTTP request for index.html and post the response headers here so we can have a look at them. Also, instead of using no-cache for the index.html file, you can try using public, must-revalidate, proxy-revalidate, max-age=0 This will allow CloudFront to store the file on the edge location, but it will force it to revalidate it with the origin with each request. If the file hasn't changed, CloudFront will not

Categories : Caching

Is it possible to create multiple cache stores using Spring's cache abstraction with redis?
According to the docs the RedisCacheManager by default saves the keys directly, without appending a prefix (cache name, which acts as a namespace). To change it and avoid clashes set 'usePrefix' to 'true': http://static.springsource.org/spring-data/data-redis/docs/current/api/org/springframework/data/redis/cache/RedisCacheManager.html

Categories : Spring

How to code a simple php5-fastcgi stdin stdout one time shot for now
To work with stdin / stdout you have to deal with them like files using the php:// wrappers $stdin = fopen("php://stdin", "r"); and $strout = fopen("php://stdout", "w"); Then you can use the normal file function (fgets, fread, fputs and fwrite etc...) to manipulate the values.

Categories : PHP

Can we cache images, css and java script in MVC3 through Output Cache?
Instead of Output Cache attribute you can use following methods to have caching of static resources: 1.Using max-age. Put below section in web.config in <configuration> -> <system.webServer> section <staticContent> <!-- Tell client to cache static files for a year --> <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" /> </staticContent> 2.Using URL versioning. Can be done by bundling. If you are using MVC3 you could look at combres on nuget. In MVC4 or above it is build-in option: Bundling and Minification

Categories : Asp Net Mvc

com.google.common.cache.Cache class not found error
Obvious answer is that; The Google guava jar is not found from the classpath dictated by the application server. The jar should be present in either WEB-INF/classes or WEB-INF/lib. Apache Tomcat also loads common classes from $CATALINA_HOME/lib folder.

Categories : Java

hibernate second level cache using jboss cache in clustered environment
I believe your problem is that you have 2 jgroups clusters setup (the cluster for the app server and the cluster for the treecache) and both clusters have the same partition name "MyPartition". You need to configure a different partition name for the treecache cluster config.

Categories : Java

Set the path of the symfony2 cache files during cache:clear
You could create a custom Symfony environment called "deploy" for your deployment and then override the different cache folders. Once you have your new environment (named "deploy" in the example below), you could override the method getCacheDir of the class app/AppKernel.php to something like this public function getCacheDir() { if ($this->environment === "deploy") { return '/the/path/to/your/symfony/cache/'.$this->environment; } else { return $this->rootDir.'/cache/'.$this->environment; } } Make sure the environment is only accessible locally by trusted users.

Categories : Symfony2

imageNamed and imageWithContentsOfFile cache image: Anyway to clear cache?
Is it possible that you are adding multiple separate UIImageViews? I.e. you are adding a local variable named detailImageView to your superview one time when this method is called, and then later on you call this method again and a new local variable UIImageView named detailImageView is added to the superview on top of the old one? If this is this case, you should see [self.view.subviews count] increasing as the method is called multiple times, adding multiple UIImageViews. In that case, you need to remove the old UIImageView before adding a new one.

Categories : IOS

How can I find location of evicted cache line in L2 cache?
Im not aware of answer to your entire question. But there is no way to know which cache line your data is mapped to. Because you dont the set number to which your data/address is mapped in L2 cache.! But I think you can know this if you are using HUGE PAGES which lets you know the mapping to L2 clearly.

Categories : C++

Google Volley - when to use Cache.remove and Cache.invalidate
Remove means you are removing the actual cached data. Invalidate means you are just marking the data as invalid. So volley will check with the server whether the data is still valid. The full expire determines whether to use the data before volley has validated it with the server. More details in the source: https://android.googlesource.com/platform/frameworks/volley/+/master/src/main/java/com/android/volley/Cache.java

Categories : Android

Browser cache- not understanding the cache related headers
Its mostly legacy, though some headers do subtly different things. Different browsers work differently (certainly in the past), and there wasn't always a standard way of doing things. Eg. IE 6 won't respond to modern caching headers. To make sure a site works correctly, we have to consider older browsers (at least for now). Have a look at this page for some good information.

Categories : HTML

Is there a way to get all of the keys out of a cache in Angular, specifically the template cache?
Since the cacheFactory implements a self-contained LRU cache, you don't need to peek at the keys since you can always to use .get() to try to get the value. You will either hit or miss the cache. I created a peek() function and submitted a patch.

Categories : Javascript

lighttpd, php, fastcgi - individual virtual host settings for notices warnings and error showing
Not sure, are looking for something like this <VirtualHost *:80> ServerName example.com DocumentRoot /var/www/domains/example.com/html ErrorLog /var/www/domains/example.com/apache.error.log CustomLog /var/www/domains/example.com/apache.access.log common php_flag log_errors on php_flag display_errors on php_value error_reporting 30719 php_value error_log /var/www/domains/example.com/php.error.log </VirtualHost> The reason 30719 is used is below All errors and warnings, as supported, except of level E_STRICT prior to PHP 5.4.0. 32767 in PHP 5.4.x, 30719 in PHP 5.3.x, 6143 in PHP 5.2.x, 2047 previously . Read here for this. You can use php_value error_reporting 2147483647 The above number, according to documentation should enable 'all' e

Categories : PHP

IIS output cache - how to add a resource to cache, whatever the path
You could use OutputCache attribute, for every Action [OutputCache(Duration=600)] public ActionResult MyAction1 Or you can set a CacheProfile [OutputCache(CacheProfile = "Cache1Hour")] public ActionResult MyAction1 ... and define it a WebConfig <system.web> <caching> <outputCacheSettings> <outputCacheProfiles> <add name="Cache1Hour" duration="3600"/> </outputCacheProfiles> </outputCacheSettings> </caching> </system.web> Furthermore, you can define where the cache will be located: You can set the Location property to any one of the following values: · Any · Client · Downstream · Server · None · ServerAndClient Tutorial with examples:

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.