Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Website loading is very slow #148

Closed
BojanKogoj opened this issue Jun 30, 2013 · 55 comments
Closed

Website loading is very slow #148

BojanKogoj opened this issue Jun 30, 2013 · 55 comments

Comments

@BojanKogoj
Copy link

I keep getting the following error: "Maximum execution time of 30 seconds exceeded". Sometimes it loads in time, but it still takes 20s to load.


Symfony \ Component \ Debug \ Exception \ FatalErrorException
open: .....\vendor\jasonlewis\basset\src\Basset\Asset.php

curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handler, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($handler, CURLOPT_HEADER, true);
curl_setopt($handler, CURLOPT_NOBODY, true);
curl_setopt($handler, CURLOPT_SSL_VERIFYPEER, false);

curl_exec($handler);

if ( ! curl_errno($handler))

APACHE 2.4.4
MYSQL 5.6.11
PHP 5.4.14

@nekwebdev
Copy link
Contributor

Humm just a wild guess but maybe you need php curl module? I'll need to check on my dev box if I have it enabled...

One way to solve all those dev environment issues will be to have a vagrant setup file in the project git so everyone can have a working dev environment if they want to :)

@BojanKogoj
Copy link
Author

cURL support enabled
cURL Information 7.29.0
So it can't be this. I'll give it a try on another device to see if it works there

@fer-ri
Copy link

fer-ri commented Jul 1, 2013

Same with you, its very slow, and give me this after completed

Symfony\Component\Debug\Exception\FatalErrorException …\bootstrap\compiled.php3317 Illuminate\Exception\Handler handleShutdown <#unknown>0

@w3smart
Copy link

w3smart commented Jul 2, 2013

The same for me. Very slow!

@nekwebdev
Copy link
Contributor

I am setting up an old MBP and will try to do a Vagrantfile to attach to this project. I don't see how this can't be an environment issue with basset . Do you have other Laravel 4 apps running basset just fine in your dev environments?

Would be nice to know if it is something specific to basset or if it's implementation in the starter site. Thanks for the feedback!!!

@nekwebdev
Copy link
Contributor

Please try the current develop branch. There is a vagrant file included and the readme is updated on how to use it.

Let me know if you still encounter the same issues in this environment. Thanks! 👍

@nekwebdev
Copy link
Contributor

Just because I think it's cool I'll repost here, to get going on the develop branch:

git clone git://github.com/andrew13/Laravel-4-Bootstrap-Starter-Site.git laravel
cd laravel
vagrant up
*** this may take a while, go grab a coffee, or two... ***
vagrant ssh
install-laravel

Go to http://127.0.0.1:8080 and enjoy your new laravel starter site running in a freshly setup Ubuntu 12.04 environment with everything needed for Laravel 4!

Want to test registration email functionality?

vagrant ssh
pysmtpd

All outgoing emails from your application will display in the ssh session!

Pretty easy huh? :)

@dzcpy
Copy link

dzcpy commented Jul 6, 2013

Same problem here, Basset has some problems under windows. I tested on my linux virtual host with same code, there isn't such problem.
I think in Basset, it's detecting resource type of a file by running curl to get that resource locally when it can not get it from extension name, it's a bit weird. Also I found that this method is called on every page so it could slow down the entire site quite a bit under windows. If you look at the console under chrome, you may also found that there is an javascript error on every page which is clearly has something to do with Basset. Mine was "Uncaught TypeError: Cannot read property 'Constructor' of undefined".

@dzcpy
Copy link

dzcpy commented Jul 6, 2013

Just found a quick hack to fix it:
remove vendor/twitter/bootstrap/js/.jshintrc
I don't know what this file is for, but from the name and content I think it's safe to delete it.
The reason why it's slowing down the site is that Basset scans the entire js directory and find all js file, since this file doesn't have a proper extension like .js or .json, Basset will have to call curl. And it's called many many times... And on a windows machine, running curl extension is much slower than anyother systems so that's why the entire site becomes slow.
Please let me know if it works, or how we can get a better solution. Thanks!

@fer-ri
Copy link

fer-ri commented Jul 7, 2013

@andyhu , i'll try it, thanks for your solution :)

@nekwebdev
Copy link
Contributor

Thanks for sharing your findings guys, I will mark this issue as closed, as it is seems to be related to the Twitter package.

I suppose most just import the files in their assets, I liked the idea of using the package better :)

@dzcpy
Copy link

dzcpy commented Jul 8, 2013

I think it's better to write a line or two about this issue in readme.md file to benefit others.This is an issue for all users which are using Windows without any exception, and it's really too slow (could take several minitues for loading just 1 page). Much slower than my Drupal site with around 100 modules enabled

@andrew13
Copy link
Collaborator

andrew13 commented Jul 8, 2013

I went ahead and asked Jason Lewis about this. We'll see if there's a way to ignore files within included directories.

@nekwebdev
Copy link
Contributor

@andyhu good call, we'll add it in the read me first chance we get!

@florinvirdol
Copy link

Same problem here, very slow loading on local: Windows 8 + XAMPP/Wamp. I also think Basset has some problems under Windows environment. [somehow related to this #133 issue ? ]

Also, when I look at console under Chrome, i get two errors:

  • "Uncaught TypeError: Cannot read property 'Constructor' of undefined"

    in file: public/assets/compiled/public/bootstrap-popover.....js

    at this line: "Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, {"
  • GET http://localhost/assets/img/bootstrap/glyphicons-halflings.png 404 (Not Found)

    [that file already exists in my public/assets/img/bootstrap/]

I tried @andyhu 's solution, but even after I removed the file from "vendor/twitter/bootstrap/js/.jshintrc", nothing was changed and I experienced the same delay.

I tested on my Debian Linux server and is loading very fast.

@andrew13
Copy link
Collaborator

andrew13 commented Jul 9, 2013

There's something up with Basset deployments with Windows. @florinvirdol can you test by removing the composer loaded twitter package and replacing it with a direct twitter bootstrap download?

@florinvirdol
Copy link

@andrew13 I don't know if i understood correctly what do you want me to test, but this is what I did, still, without any success on getting better loading time (just got rid of javascript errors that appeared on console):

  • in the three folders (css, img, js) from /public/assets/ I replaced the corresponding existing bootstrap files with the ones from twitter bootstrap downloaded folder;
  • after that, I also modified these lines from the file views/site/layout/default.blade.php:
    • line {{ Basset::show('public.css') }} replaced with:
      <link rel="stylesheet" type="text/css" href="....../public/assets/css/bootstrap.css">
    • line {{ Basset::show('public.js') }} replaced with:
      <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>

      <script src="....../public/assets/js/bootstrap/bootstrap.js"></script>

@andrew13
Copy link
Collaborator

andrew13 commented Jul 9, 2013

@florinvirdol
Copy link

@andrew13 I modified (comment/uncomment) the two lines related to bootstrap.js in that config file as you suggested, and now, it seems to have a better loading time! Thanks a lot!

So this is the best solution, right? Should be used by default direct twitter bootstrap download instead of composer loaded twitter package?

@BojanKogoj
Copy link
Author

@andrew13 those two lines indeed help with it, I rarely get 30s error. However it is still by far too slow, takes around 15+s to load, while it takes ~2s on my RPI (nginx). There has to be another issue

@andrew13
Copy link
Collaborator

It's not the best solution, it's just a workaround as I think there is still a bug within Basset on Windows. We should be able to load the directory from the composer package in windows like we can in linux.

@Surreal9
Copy link

Has there been any word back on this? I can't find any reference under Basset's github project of any performance issues..

@georgerhewitt
Copy link

still loading slow for me on windows did a fresh install today.

@andrew13
Copy link
Collaborator

I commented in Basset: jasonlewis/basset#177

It seems Basset has issues with the Bootstrap included meta files. I don't have windows so I'm unable to debug this. I'd welcome anyone to help improve Basset or the windows include. I'm sorry but I can't help without a system to debug on.

@georgerhewitt
Copy link

@andrew13 thanks for the quick reply, I'll see what I can on my end.

@andrew13
Copy link
Collaborator

Thanks for taking the time to attempt to debug it.

@drekinov
Copy link

Hello, i have very similar problem on Windows 8 + xampp 1.8.2. Up to 44 seconds on page load. I trace the problem to loading files from CDN urls. I have jquery from ajax.googleapis.com and font-awesome from their CDN. Each consume 22 seconds. After i remove them from collections => 0.2 seconds :)
So i continue to trace the problem from Basset\Factory\AssetFactory::make
So please try commenting out cdn resources from collections and test loading times, while i am tracing.

Edited: The problem comes from Basset\Factory\AssetFactory::buildAbsolutePath() - realpath takes ages to resolve the CDNs without http or https.

@jochan
Copy link

jochan commented Jul 27, 2013

You're right - after changing my realpath_cache_size in php.ini to 64k from 16k on my Win7 + XAMPP setup, it sped along rather smoothly.

@amer3000
Copy link

amer3000 commented Aug 5, 2013

@johnygold
Copy link

Using the config.php above will load the assets individually. However, I have many assets, so I want to keep using the $collection->requireDirectory method. However this doesn't work on windows (mac seems to work fine). So scanning the different directories here looks buggy. I always get the cUrl timeout. (note: when I disable stylesheets, and just load the javascript, it actually gets there, but takes a long time)

         $directory = $collection->directory('assets/stylesheets', function($collection)
         {
             //$collection->requireDirectory('less')->apply('Less');
             //$collection->requireDirectory('sass')->apply('Sass');
             //$collection->requireDirectory();
         });

         $directory->apply('CssMin');
         $directory->apply('UriRewriteFilter');

         // Switch to the javascripts directory and require the "coffeescript" directory. As
         // with the above directories we'll apply the CoffeeScript filter to the directory
         // so the built collection contains valid JS.
         $directory = $collection->directory('assets/javascripts', function($collection)
         {
             //$collection->requireDirectory('coffeescripts')->apply('CoffeeScript');
             $collection->requireDirectory();
         });

Note:

After further investigation it seems that my hidden window files like .DS_store etc. were interfering. So make sure you have all hidden files removed from those folders.

@vladoa
Copy link

vladoa commented Aug 11, 2013

I have the same problem on my Windows machine. Is there a final guide on how to overcome this?

@xdimension
Copy link

I had the slow website problem too in Windows, and I have solved it by adding 'http://' to all remote assets. This solution actually had been addressed by @drekinov in his comment, but newbie like me didn't get it :p

So basically I made some changes in this file app/config/packages/jasonlewis/basset/config.php:

 $collection->directory('assets/js', function($collection)
            {
                $collection->javascript('//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js');
                //$collection->add('bootstrap/bootstrap.js');
                $collection->requireDirectory('../../../vendor/twbs/bootstrap/js');
            })->apply('JsMin');

to:

 $collection->directory('assets/js', function($collection)
            {
                $collection->javascript('http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js');
                $collection->add('bootstrap/bootstrap.js');
                $collection->requireDirectory('../../../vendor/twbs/bootstrap/js');
            })->apply('JsMin');

I also need to remove a file like @andyhu said in his comment

So far, it looks like the problem has gone... :)

@amer3000
Copy link

@xdimension and @drekinov fix is way faster.

@andrew13
Copy link
Collaborator

Added this information to the readme. Thanks all!

@christoferd
Copy link

[b]Yes - Basset, curl issue[/b]
I have done a cachegrind/webgrind on fresh install of Laravel 4 Starting Point (andrew13)
All is updated and takes 10 seconds per page load. Almost all of the "cost"
[b]is caused by one line - see screenshots...[/b]

screenshot_2013-09-01_19-55-09
screenshot_2013-09-01_19-54-28

@daveit
Copy link

daveit commented Sep 7, 2013

I've tried all the suggestions mentioned here, but my speed is so slow the development environment is unusable!
Anyone have any other ideas ?
Could I remove Basset for now and come back to it ?
Any side effects or dependency issues I might run into ?
Cheers, Dave

@christoferd
Copy link

@daveit
For those to work, using "../", must have "Symlinks" enabled in Apache/webserver. Apache: can use .htaccess in root folder to enable.

With Basset, I've done a few things:

  1. remove any references to outside files (eg. jquery via google cdn)
  2. copy files so that they are all under app/assets/
  3. update references to use folders in assets only
    This has sped things up a lot for me. Hope it helps.

Important Note: Basset github readme says to not use any files outside of assets folder. Take a look at reasoning.

@andrew13
Copy link
Collaborator

andrew13 commented Sep 8, 2013

Moving everything into the public folder is on my todo list. As I think that's causing a lot of the issues here.

@fasilkk
Copy link

fasilkk commented Sep 10, 2013

I also tried all suggestion mentioned here. Finally i did a fresh installation without bootstrap(bootstrap package removed from composer) . but still it is slow without bootstrap.

@christoferd
Copy link

More ideas,

In the basset config, I made sure there were no requests to full
directories.

Instead of "add()" use "stylesheet" or "javascript" (or whatever the
function is)

In the end, I've run the cachegrind/webgrind and it's definitely an issue
with CURL being called on the local host machine. No idea why that's an
issue, but it was. Most likely will need the author to dig into it and help
us more.

and last but not least... General Windows Rule; Restart Computer : )

On 10 September 2013 19:41, fasilkk [email protected] wrote:

I also tried all suggestion mentioned here. Finally i did a fresh
installation without bootstrap(bootstrap package removed from composer) .
but still it is slow without bootstrap.


Reply to this email directly or view it on GitHubhttps://github.com//issues/148#issuecomment-24146033
.

@virendrapatidar
Copy link

Tried everything from the above comments but its not helping in my case on windows. Working fine on mac.
In my case, its only opening the home page and that too without any CSS effect...and toooooo slow....

@virendrapatidar
Copy link

I have removed Basset and twbs from composer. Loading all js and css from local twbs directly (without basset) and its working on windows but still slow compare to Mac..

@christoferd
Copy link

This problem crept up again. Finally I removed Basset completely.
Guess what.... that didn't fix the issue :-(
More investigation and troubleshooting finally led to another solution
Change your Domain/Host Name!
Believe it or not, I fixed this by just changing the domain name/host
from "dev.example" to "example", (notice there is no dot "." in the 2nd one)
I believe that changing it to "example.dev" may also speed it up. Yep, just tried it, this works fast too.
running on local dev machine.
So the issue is only when I change host to "dev.example"... seems like a long TLD causes issues, wonder why ?:-/ Windows, WAMP, Laravel, Apache, PHP extension.... which is at fault here?
Is this a laravel issue? Seems so odd that a host name will cause 5 seconds of delay :-/

@virendrapatidar
Copy link

You mean changing the domain name / machine name and updating the same in start.php?
My machine name is without any domain , its just one word and without "." Its still slow on windows...

@christoferd
Copy link

I mean, "host name".
eg. http://myhostname.dev/

  • Update it in config/app.php
  • Updated it in my "hosts" file, to point to 127.0.0.1
  • Updated my vhost in apache httpd-vhosts.conf

Cheers - Chris

On 23 September 2013 16:46, virendrapatidar [email protected]:

You mean changing the domain name / machine name and updating the same in
start.php?
My machine name is without any domain , its just one word and without "."
Its still slow on windows...


Reply to this email directly or view it on GitHubhttps://github.com//issues/148#issuecomment-24901416
.

@folkevil
Copy link

folkevil commented Oct 8, 2013

i copied jquery.min.js ad jquery.dataTables.min.js to "public/assets/js", replaced $collection->javascript with $collection->add. Problem solved :)

@Tommixoft
Copy link

FINALLY!!!!!!!! After adding "http:" to js file addresses who starts with stupid "//" (why not just http:// or https:// ?) - my site now loads pretty fast :)
thanks.

Win7
Xamp
Apache 2.4.4
PHP 5.4.12

PS thank you for this quick starter! if not this i wouldn't even use Laravel :)

@geding
Copy link

geding commented Oct 13, 2013

Resolved this same way, thanks @drekinov and @xdimension !

@Seb7
Copy link

Seb7 commented Oct 16, 2013

ah,finally works here too... What @drekinov and @xdimension said. Adding http:" to js file addresses that start with "//" worked.

@kiwina
Copy link

kiwina commented Dec 16, 2013

removing vendor/twbs/bootstrap/js/.jshintrc was the solution for me from unusable to what i expect it to be

@doveraudio
Copy link
Contributor

after going over these threads a dozen times, I put this fix together. I barely managed to get this up here, but i figured i'd share it as soon as i got it working for myself. all the credit belongs to you guys.

https://github.com/doveraudio/Laravel-4-Bootstrap-Starter-Site

@eComEvo
Copy link

eComEvo commented Apr 10, 2014

@andyhu solution to just delete vendor/twbs/bootstrap/js/.jshintrc fixed the load time issue on my Windows 8 AMPPS server.

@christoferd
Copy link

IMO Deleting files from vendor folder is problematic as you would have to
remember to do this upon every update. :-/
Better to help developer solve it in the distribution files.

  • Chris

On 10 April 2014 10:44, Joshua B [email protected] wrote:

@andyhu https://github.com/andyhu solution to just delete
vendor/twbs/bootstrap/js/.jshintrc fixed the load time issue on my
Windows 8 AMPPS server.

Reply to this email directly or view it on GitHubhttps://github.com//issues/148#issuecomment-40032608
.

@heitorglockner
Copy link

Hi,
use the command:
php artisan config:publish jasonlewis/basset
and after use
php artisan basset:build --production

@ramazo
Copy link

ramazo commented Apr 15, 2014

????

2014-04-15 1:33 GMT+01:00 heitorglockner [email protected]:

Hi,
use the command:
php artisan config:publish jasonlewis/basset
and after use
php artisan basset:build --production


Reply to this email directly or view it on GitHubhttps://github.com//issues/148#issuecomment-40433877
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests