add files
|
1 | |
2 |
=encoding utf8 |
|
3 | ||
4 |
=head1 NAME |
|
5 | ||
6 |
Mojolicious::Guides::FAQ - Frequently Asked Questions |
|
7 | ||
8 |
=head1 OVERVIEW |
|
9 | ||
10 |
This document contains answers for the most frequently asked questions about |
|
11 |
L<Mojolicious>. |
|
12 | ||
13 |
=head1 QUESTIONS |
|
14 | ||
15 |
=head2 How does Mojolicious compare to other Perl web frameworks? |
|
16 | ||
17 |
The short answer is "it doesn't", because we interpret the words |
|
18 |
"web framework" much more literally than others. With the emergence of the |
|
19 |
C<real-time web> and new technologies such as C<WebSockets>, we are facing new |
|
20 |
challenges that go way beyond what commonly used modules like L<LWP> were |
|
21 |
designed for. Because of this, L<Mojolicious> contains a whole new HTTP |
|
22 |
client/server stack called L<Mojo>, which was heavily inspired by the original |
|
23 |
C<LWPng> effort and carefully designed with these new requirements in mind. So |
|
24 |
while some of the higher abstraction layers might look similar to other web |
|
25 |
frameworks, it actually defines a whole new category and could even be the |
|
26 |
foundation for more advanced ones in the future. |
|
27 | ||
28 |
=head2 Why doesn't Mojolicious have any dependencies? |
|
29 | ||
30 |
We are optimizing L<Mojolicious> for user-friendliness and development speed, |
|
31 |
without compromises. While there are no rules in |
|
32 |
L<Mojolicious::Guides::Contributing> that forbid dependencies, we do currently |
|
33 |
discourage adding non-optional ones in favor of a faster and more painless |
|
34 |
installation process. And we do in fact already use several optional CPAN |
|
35 |
modules such as L<EV>, L<IO::Socket::IP>, L<IO::Socket::SSL> and L<Plack> to |
|
36 |
provide advanced functionality if they are installed. |
|
37 | ||
38 |
=head2 Why reinvent wheels? |
|
39 | ||
40 |
Because we can make them rounder. Components specifically designed for |
|
41 |
user-friendliness and development speed are not easy to come by. We are strong |
|
42 |
believers of the Perl mantra "There is more than one way to do it", and our |
|
43 |
quest is to develop the best possible solutions for these two criteria. |
|
44 | ||
45 |
=head2 What about backwards compatibility? |
|
46 | ||
47 |
In conformance with L<Mojolicious::Guides::Contributing>, we will always |
|
48 |
deprecate a feature before removing or changing it in incompatible ways |
|
49 |
between major releases. New features can however be marked as experimental to |
|
50 |
explicitly exclude them from these rules. This gives us the necessary freedom |
|
51 |
to ensure a healthy future for L<Mojolicious>. So, as long as you are not |
|
52 |
using anything marked experimental, untested or undocumented, you can always |
|
53 |
count on backwards compatibility, everything else would be considered a bug. |
|
54 | ||
55 |
=head2 Why not split up Mojolicious into many smaller distributions? |
|
56 | ||
57 |
Because there are no advantages, it drastically increases maintenance costs |
|
58 |
and installation times without giving us anything in return. It would only |
|
59 |
make sense if we wanted to pass ownership of a module to a new maintainer, |
|
60 |
which we already have done in the past. |
|
61 | ||
62 |
=head2 What does the error "Maximum message size exceeded" mean? |
|
63 | ||
64 |
To protect your applications from excessively large requests and responses, |
|
65 |
our HTTP parser has a cap after which it will automatically stop accepting new |
|
66 |
data, and in most cases force the connection to be closed. This limit is |
|
67 |
around C<10MB> by default, you can use the MOJO_MAX_MESSAGE_SIZE environment |
|
68 |
variable to change this value. |
|
69 | ||
70 |
=head2 What does the error "Maximum line size exceeded" mean? |
|
71 | ||
72 |
This is a very similar protection mechanism to the one described in the |
|
73 |
previous answer, but a little more specific. It limits the maximum length of |
|
74 |
any C<\x0d\x0a> terminated part of a HTTP message, such as request line, |
|
75 |
status line and headers. This limit is around C<10KB> by default, you can use |
|
76 |
the MOJO_MAX_LINE_SIZE environment variable to change this value. |
|
77 | ||
78 |
=head2 What does the error "Maximum buffer size exceeded" mean? |
|
79 | ||
80 |
This protection mechanism is very similar to those mentioned in the two |
|
81 |
previous answers. It limits how much content the HTTP parser is allowed to |
|
82 |
buffer when parsing chunked, compressed and multipart messages. This limit is |
|
83 |
around C<256KB> by default, you can use the MOJO_MAX_BUFFER_SIZE environment |
|
84 |
variable to change this value. |
|
85 | ||
86 |
=head2 What does the error "EV does not work with ithreads" mean? |
|
87 | ||
88 |
The L<Mojolicious> user agent and web servers are based on an event loop that |
|
89 |
supports multiple reactor backends. One of these backends is L<EV>, it is very |
|
90 |
fast and will be automatically used if installed. On Windows however, the |
|
91 |
C<ithreads> based C<fork()> emulation can interfere with it, and you may have |
|
92 |
to use the MOJO_REACTOR environment variable to enforce a more portable one. |
|
93 | ||
94 |
MOJO_REACTOR=Mojo::Reactor::Poll |
|
95 | ||
96 |
=head2 What does "Your secret passphrase needs to be changed" mean? |
|
97 | ||
98 |
L<Mojolicious> uses a secret passphrase for security features such as signed |
|
99 |
cookies. It defaults to the moniker of your application, which is not very |
|
100 |
secure, so we added this log message as a reminder. You can change the |
|
101 |
passphrase with the attribute L<Mojolicious/"secret">. |
|
102 | ||
103 |
app->secret('My very secret passphrase.'); |
|
104 | ||
105 |
=head2 What does "Nothing has been rendered, expecting delayed response" mean? |
|
106 | ||
107 |
L<Mojolicious> has been designed from the ground up for non-blocking I/O and |
|
108 |
event loops. So when a new request comes in and no response is generated right |
|
109 |
away, it will assume that this was intentional and return control to the web |
|
110 |
server, which can then handle other requests while waiting for events such as |
|
111 |
timers to finally generate a response. |
|
112 | ||
113 |
=head2 What does "Inactivity timeout" mean? |
|
114 | ||
115 |
To protect your applications from denial-of-service attacks, all connections |
|
116 |
have an inactivity timeout which limits how long a connection may be inactive |
|
117 |
before being closed automatically. It defaults to C<20> seconds for the user |
|
118 |
agent and C<15> seconds for all built-in web servers, and is commonly referred |
|
119 |
to as C<inactivity_timeout>. This timeout always applies, so you might have to |
|
120 |
tweak it for applications that take a long time to process a request. |
|
121 | ||
122 |
=head2 What does "Premature connection close" mean? |
|
123 | ||
124 |
This error message is often related to the one above, and means that the web |
|
125 |
server closed the connection before the user agent could receive the whole |
|
126 |
response. |
|
127 | ||
128 |
=head2 What does "Worker 31842 has no heartbeat, restarting" mean? |
|
129 | ||
130 |
As long as they are accepting new connections, Hypnotoad worker processes send |
|
131 |
heartbeat messages to the manager process at regular intervals, to signal that |
|
132 |
they are still responsive. A blocking operation such as an infinite loop in |
|
133 |
your application (or active connections after a worker has stopped accepting |
|
134 |
new connections) can prevent this, and will force the affected worker to be |
|
135 |
restarted after a timeout. This C<heartbeat_timeout> defaults to C<20> seconds |
|
136 |
and can be extended if your application requires it. |
|
137 | ||
138 |
=head1 MORE |
|
139 | ||
140 |
You can continue with L<Mojolicious::Guides> now or take a look at the |
|
141 |
L<Mojolicious wiki|http://github.com/kraih/mojo/wiki>, which contains a lot |
|
142 |
more documentation and examples by many different authors. |
|
143 | ||
144 |
=head1 SUPPORT |
|
145 | ||
146 |
If you have any questions the documentation might not yet answer, don't |
|
147 |
hesitate to ask on the |
|
148 |
L<mailing-list|http://groups.google.com/group/mojolicious> or the official IRC |
|
149 |
channel C<#mojo> on C<irc.perl.org>. |
|
150 | ||
151 |
=cut |