Hi,
This is my first attempt at a web app, and I'm using Hunchentoot as my web =
server. I have an easy-handler and a simple function that take care of a st=
atic html page. The problem I have is in loading jquery.js in my HTML file =
(ie. <script type =3D "text/javascript" src=3D"jquery-1.7.2.min.js"></scrip=
t>). While everything works, it takes around 30 seconds to load the page wi=
th that line in there. JQuery isn't necessary for this application yet... b=
ut I was wondering if there was a better way to go about using it with Lisp=
and Hunchentoot? I've looked all over but there isn't much to go on.
Thanks,
Jeff
ps. Here is my code:
;;;; skipping package stuff and showing handler ;;;;
;; Reads in a file and returns it as a string.
(defun get-page (path)
(with-open-file (str path :direction :input)
(with-output-to-string (s)
(do ((line (read-line str nil)
(read-line str nil)))
((null line))
(format s "~A" line)))))
(define-easy-handler (frontpage :uri "/") ()
(setf (hunchentoot:content-type*) "text/html")
(get-page "./www/index.html"))
;; Start the Server
(defun start-server ()
(hunchentoot:start (make-instance 'hunchentoot:easy-acceptor :port 8080 :=
document-root #p"/<path-to-app>/src/www/")))
|
|
0
|
|
|
|
Reply
|
jeffreydbyrd (2)
|
6/5/2012 7:29:51 PM |
|
On Tue, 05 Jun 2012 12:29:51 -0700, Jeff Byrd wrote:
> Hi,
>
> This is my first attempt at a web app, and I'm using Hunchentoot as my
> web server. I have an easy-handler and a simple function that take care
> of a static html page. The problem I have is in loading jquery.js in my
> HTML file (ie. <script type = "text/javascript"
> src="jquery-1.7.2.min.js"></script>). While everything works, it takes
> around 30 seconds to load the page with that line in there. JQuery isn't
> necessary for this application yet... but I was wondering if there was a
> better way to go about using it with Lisp and Hunchentoot? I've looked
> all over but there isn't much to go on.
>
> Thanks,
> Jeff
>
> ps. Here is my code:
>
> ;;;; skipping package stuff and showing handler ;;;;
>
> ;; Reads in a file and returns it as a string.
> (defun get-page (path)
> (with-open-file (str path :direction :input)
> (with-output-to-string (s)
> (do ((line (read-line str nil)
> (read-line str nil)))
> ((null line))
> (format s "~A" line)))))
>
>
> (define-easy-handler (frontpage :uri "/") ()
> (setf (hunchentoot:content-type*) "text/html")
> (get-page "./www/index.html"))
>
>
> ;; Start the Server (defun start-server ()
> (hunchentoot:start (make-instance 'hunchentoot:easy-acceptor :port
> 8080 :document-root #p"/<path-to-app>/src/www/")))
Hi Jeff,
I'm no hunchentoot expert, but did you check in your browser whether
jquery has been finally loaded at all?
When I tried your example, it didn't load -- there was no waiting for 30
seconds either. After adding a handler for the script like
(define-easy-handler (tralla :uri "/jquery-1.7.min.js") ()
(setf (hunchentoot:content-type*) "application/x-javascript")
(get-page "web-app/jquery-1.7.min.js"))
All loaded find. I'm not sure though if this is the right thing to do in
general.
Best,
Stefan
|
|
0
|
|
|
|
Reply
|
StefanMandl (55)
|
6/5/2012 10:00:09 PM
|
|
On Tuesday, June 5, 2012 6:00:09 PM UTC-4, Stefan Mandl wrote:
> On Tue, 05 Jun 2012 12:29:51 -0700, Jeff Byrd wrote:
>=20
> > Hi,
> >=20
> > This is my first attempt at a web app, and I'm using Hunchentoot as my
> > web server. I have an easy-handler and a simple function that take care
> > of a static html page. The problem I have is in loading jquery.js in my
> > HTML file (ie. <script type =3D "text/javascript"
> > src=3D"jquery-1.7.2.min.js"></script>). While everything works, it take=
s
> > around 30 seconds to load the page with that line in there. JQuery isn'=
t
> > necessary for this application yet... but I was wondering if there was =
a
> > better way to go about using it with Lisp and Hunchentoot? I've looked
> > all over but there isn't much to go on.
> >=20
> > Thanks,
> > Jeff
> >=20
> > ps. Here is my code:
> >=20
> > ;;;; skipping package stuff and showing handler ;;;;
> >=20
> > ;; Reads in a file and returns it as a string.
> > (defun get-page (path)
> > (with-open-file (str path :direction :input)
> > (with-output-to-string (s)
> > (do ((line (read-line str nil)
> > (read-line str nil)))
> > ((null line))
> > (format s "~A" line)))))
> >=20
> >=20
> > (define-easy-handler (frontpage :uri "/") ()
> > (setf (hunchentoot:content-type*) "text/html")
> > (get-page "./www/index.html"))
> >=20
> >=20
> > ;; Start the Server (defun start-server ()
> > (hunchentoot:start (make-instance 'hunchentoot:easy-acceptor :port
> > 8080 :document-root #p"/
> /src/www/")))
>=20
> Hi Jeff,
>=20
> I'm no hunchentoot expert, but did you check in your browser whether=20
> jquery has been finally loaded at all?
> When I tried your example, it didn't load -- there was no waiting for 30=
=20
> seconds either. After adding a handler for the script like
>=20
> (define-easy-handler (tralla :uri "/jquery-1.7.min.js") ()
> (setf (hunchentoot:content-type*) "application/x-javascript")
> (get-page "web-app/jquery-1.7.min.js"))
>=20
> All loaded find. I'm not sure though if this is the right thing to do in=
=20
> general.
>=20
> Best,
> Stefan
Hi Stefan and thanks for your reply. Adding another handler does speed it u=
p, but there appears to be an additional hang-up.
After playing with it a bit more and checking my log, it looks like it's ge=
tting caught up loading the .css file ... but only after every 2 reloads or=
so (I'm guessing the cache provides it half the time, and the behavior is =
consistent across all browsers).
I'm not sure if this is related to Hunchentoot or Lisp so I'll head on back=
to the Google-search bar. But if anybody has some suggestions, I'd be happ=
y to hear them!
Thanks,
Jeff
|
|
0
|
|
|
|
Reply
|
jeffreydbyrd (2)
|
6/6/2012 2:04:02 PM
|
|
On Wed, 06 Jun 2012 07:04:02 -0700, Jeff Byrd wrote:
> On Tuesday, June 5, 2012 6:00:09 PM UTC-4, Stefan Mandl wrote:
>> On Tue, 05 Jun 2012 12:29:51 -0700, Jeff Byrd wrote:
>>
>> > Hi,
>> >
>> > This is my first attempt at a web app, and I'm using Hunchentoot as
>> > my web server. I have an easy-handler and a simple function that take
>> > care of a static html page. The problem I have is in loading
>> > jquery.js in my HTML file (ie. <script type = "text/javascript"
>> > src="jquery-1.7.2.min.js"></script>). While everything works, it
>> > takes around 30 seconds to load the page with that line in there.
>> > JQuery isn't necessary for this application yet... but I was
>> > wondering if there was a better way to go about using it with Lisp
>> > and Hunchentoot? I've looked all over but there isn't much to go on.
>> >
>> > Thanks,
>> > Jeff
>> >
>> > ps. Here is my code:
>> >
>> > ;;;; skipping package stuff and showing handler ;;;;
>> >
>> > ;; Reads in a file and returns it as a string.
>> > (defun get-page (path)
>> > (with-open-file (str path :direction :input)
>> > (with-output-to-string (s)
>> > (do ((line (read-line str nil)
>> > (read-line str nil)))
>> > ((null line))
>> > (format s "~A" line)))))
>> >
>> >
>> > (define-easy-handler (frontpage :uri "/") ()
>> > (setf (hunchentoot:content-type*) "text/html")
>> > (get-page "./www/index.html"))
>> >
>> >
>> > ;; Start the Server (defun start-server ()
>> > (hunchentoot:start (make-instance 'hunchentoot:easy-acceptor :port
>> > 8080 :document-root #p"/
>> /src/www/")))
>>
>> Hi Jeff,
>>
>> I'm no hunchentoot expert, but did you check in your browser whether
>> jquery has been finally loaded at all?
>> When I tried your example, it didn't load -- there was no waiting for
>> 30 seconds either. After adding a handler for the script like
>>
>> (define-easy-handler (tralla :uri "/jquery-1.7.min.js") ()
>> (setf (hunchentoot:content-type*) "application/x-javascript")
>> (get-page "web-app/jquery-1.7.min.js"))
>>
>> All loaded find. I'm not sure though if this is the right thing to do
>> in general.
>>
>> Best,
>> Stefan
>
> Hi Stefan and thanks for your reply. Adding another handler does speed
> it up,
Strange. I mean either the file is handled or not. Why should there be a
speed-up?
> but there appears to be an additional hang-up.
>
> After playing with it a bit more and checking my log, it looks like it's
> getting caught up loading the .css file
For debugging the client-server interactions, I found Chrome's onboard
developer tools really helpful (or firebug for firefox).
> ... but only after every 2
> reloads or so (I'm guessing the cache provides it half the time, and the
> behavior is consistent across all browsers).
>
> I'm not sure if this is related to Hunchentoot or Lisp so I'll head on
> back to the Google-search bar. But if anybody has some suggestions, I'd
> be happy to hear them!
I still have no clue how to configure hunchentoot, but when adding a
handler for the javascript helped, maybe adding another for the css is
worth a try ;-)
|
|
0
|
|
|
|
Reply
|
StefanMandl (55)
|
6/6/2012 7:09:07 PM
|
|
|
3 Replies
34 Views
(page loaded in 0.268 seconds)
|