6

Could it be that a POST request is limited to size? I have a large procedure I want to cache the output from. Basically I want to store a lare html-table in cache because of the growth a particulary project, the number of queries and thereby the responsetime is getting out of hand.

Now i'm sending the large output which is retrieved by an ajax-call, in another ajax-call (after the first one completes), but I only get a small piece of the data back. I think my ajaxfunction is correct because the stored output is always the same (in characters). But I'm missing about 90% of the output in the cache...

Ben Fransen
  • 10,884
  • 18
  • 76
  • 129
  • It's configurable. See php.ini. – John Oct 03 '11 at 17:28
  • possible duplicate of [PHP: whats the total length of a post global variable?](http://stackoverflow.com/questions/2276759/php-whats-the-total-length-of-a-post-global-variable) – Frank Farmer Oct 03 '11 at 17:29
  • post_max_size, and memory_limit. Your webserver has a limit as well. I believe nginx defaults to a fairly conservative limit, while apache's limit defaults to 2 gigs. – Frank Farmer Oct 03 '11 at 17:30
  • I guess the size transmitted at this moment is only a few KB... – Ben Fransen Oct 03 '11 at 17:36
  • I think you should better outline how the request looks like that is causing the problem (after caching). The first part of your question might be misleading. – hakre Oct 03 '11 at 17:46

3 Answers3

9

there is an 8 Mb max size for the POST method, by default (can be changed by setting the post_max_size in the php.ini file).

"Could it be that a POST request is limited to size?"

Yes, there is a PHP setting: post_max_size

hakre
  • 193,403
  • 52
  • 435
  • 836
Patrick Desjardins
  • 136,852
  • 88
  • 292
  • 341
  • Thanks for the replies! I don't think this is going to solve my issue. I think the outputsource is about a few KB only, not multiple MB's.... – Ben Fransen Oct 03 '11 at 17:35
4

I just ran into this problem myself and found that since PHP 5.3.9 there is a new setting available which restricts the total number of post variables (not just the size).

max_input_vars = 1000

This may have been the same issue you were running into if you were using a nightly or release candidate version of PHP at the time.

supakaity
  • 380
  • 2
  • 8
2

Look for these settings in your php.ini

; Maximum size of POST data that PHP will accept.
; http://php.net/post-max-size
post_max_size = 8M

; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 128M

post_max_size specifies the maximum size of a POST, and since it has to be contained in memory, memory limit has to be bigger. The memory, will have to contain the running program and all the heap variables, including the POST.

If you increase only post_max_size over or near to the memory limit and forget to increase memory_limit, the POST size will be limited to a lower value when the memory is exhausted.

In this example you can see the default settings.

stivlo
  • 83,644
  • 31
  • 142
  • 199