Code Monkey home page Code Monkey logo

flatten's People

Contributors

anahkiasen avatar barryvdh avatar robbanl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flatten's Issues

Twig Support

Hi,

I'm working on Twig Support for Flatten and just wanted to make sure first that that feature doesn't already exist and that there isn't some reason why it hasn't been implemented.

Basing off the Blade example in the readme, it would look like this in Twig:

{% cache('articles', 10) %}
    {% for article in articles %}
        {{ article.name }}
    {% endfor %}
{% endcache %}

Only GET methods?

The docs say only GET methods are cached, but is that true? In my logs, POST files are cached.. This killed a contact form. I can find it for the kickstart method, not for the regular method, or have I configured something wrong?

Only GET requests get cached as all the other methods are dynamic by nature.

Environments config is confusing

// The environments in which Flatten should not run
'environments' => array(),

That seems a bit counterintuitive. A config option named environments sound like it should define the env(s) where Flatten would run, not where it's ignored.

Even though it would break BC, would you consider flipping the logic, so environments defines where you want it to run ... or alternatively, rename the config option ignore_environments?

Keep re-creating the same cache

Hi,

Let's say I'm caching "movies_1".

When I refresh the page, Flatten creates a new cache even if there's already a cache in the database.

refreshing 5 times creates 5 rows in the database with the same key and content.

I think this is a bug.

flatten:build

When running artisan flatten:build I had a few errors.
I first ran into an issue exceeded memory size. Caused by the hasPagesToCrawl method.

Looks like items are never removed from $this->queue so that array is never empty. I fixed that so that items were unset from the queue during crawlPage()

But then I also had issues where my crawled pages were getting cached using the wrong url. It was using the hash of my homepage URL.

I fixed this too by creating a set Hash method of the CacheHandler

I'm reluctant to submit a PR for this, as I think it's a bug that I'm not fixing properly.
Does flatten:build work for you @Anahkiasen?

Cache skip Laravel load

This package looks very promising, but I was wondering if it was possible to skip loading Laravel at all. It seems to a lot of files have to be loaded, to just start Laravel.

Would it be possible to capture the request and respond with the cache before even starting Laravel? Similar to Wordpress WP-Super Cache (http://wordpress.org/plugins/wp-super-cache/) or Drupal Boost (https://drupal.org/project/boost)

Either via .htaccess, rewriting to the cached version, or with php (just outputting the file)
(Only for anonymous visitors and GET requests offcourse)

Add Cached-by Meta

In order to debug caching would be nice to have a header or a html comment in the output

<!-- Cached by Flatten on 2015-08-05 19:55:50 -->

Blade rendering only text

Hello guys, I'm trying to use the Runtime Cache, but when I put this in the layout.blade.php:

@cache('foo', 10)
      bar
@endcache

The render result is @cache('foo', 10) bar @endcache

Any ideia?

BuildCommand causes a segmentation fault

When running 'php artisan flatten:build', a segmentation fault occurs, after the last page is cached. I'm not sure what information would help track this down. This happened last night, on a BlueHost shared server, and just now on a homestead box.

I'm just shooting in the dark here, but I'm assuming it may have to do with the CrawlPages recursion code. When building a cache with 103 pages that get queued, a error occurs if xdebug is enabled, saying that the maximum nesting level was exceeded (defaults to 100, I had it set to 200). Also, there are a few 404 errors, from a few pages that have links, but don't yet exist. (Those 404s are the only errors I see in laravel.log.)

If I'm asked to, when I find time, I can help try to find the root-cause.

No cache if user is authenticated

It would be great if there is a way to show non cached pages to authenticated users
Show cache pages only if user is not authenticated

How to Cache Only a Part of My View

My master layout is almost like following:

<html>
<head>

</head>
<body>
    <div id="wrapper" class="clearfix">

        @include(layouts.header')

        <?php Flatten::start() ?>
        @yield('content')
        <?php Flatten::end() ?>

        @include('layouts.footer')

    </div

</body>
</html>

But I only want to cache whatever is generated in @yield('content') part. Why because my header includes login and logout buttons, if they are also cached, even if user is logged in, he is shown "Login".

Is it possible to cache only this part of the page keeping rest of the page dynamic?

Kickstarter only for non logged in users

Can someone tell me how to use kickstarter method, but only for non logged in users?

The issue is that with kickstarter it doesn't check the config and as it don't use laravel there is no simple way to Auth::check()

Can someone help me with this?

File caching or memcached/redis?

I assume that by default the contents are saved in flat files. Just asking, but will be there a support for memcached/redis in the future? :)

Thanks!
Alessio

Flatten Install issues

Hello!

  1. In the readme you specifying "anahkiasen/flatten": "dev-develop" to be included in the composer.json but that doesn't work, which works is "anahkiasen/flatten": "dev-master".
  2. After following your instructions to install the package, which installed correctly with composer upadate, the class Flatten is not recognised by Laravel though the artisan config:publish anahkiasen/flatten command generates the required config files, even the artisan flatten:build gives the following error:

Cached / (0 in queue)
Page at "http://XXXXXXXXX" returned a 404
{"error":{"type":"ErrorException","message":"Undefined property: Flatten\Crawler\BuildCommand::$command","file":"D:\SkyDive\SkyDrive\www\quick24\vendor\anahkiasen\flatten\src\Flatten\Crawler\BuildCommand.php","line":46}}

P.S. The cache file is created so the caching works.

Can you please let me know what the solution for this issue?

Thanks!

Also not working on L5.1

It looks promising but can't get it to work on L5.1. Tried tweaking around but reading the other comments something tells me this does not work at all for L5.1.

Can you please update this in the readme?

csf token

how we can use this on pages have csrf token ?

Laravel: Way to detect if partial is cached for View Composer not making it's job useless

To prevent from composing data for already cached view I did the following workaround:

class MenuPartialComposer {
    public function compose($view) {
        if (Cache::has('flatten-section-menu')) {
            return;
        }

        // do the rest here
    }
}

User of Flatten shouldn't know that it uses Cache component or flatten-section- prefix. I believe that there should be some method in Flatten like Flatten::hasCachedSection() or whatever. Since support for Laravel sections seems to be just an addon in Flatten, I wasn't sure how to implement it the best way so I'm not proposing any commit.

Undefined Variables

Helo I try runtime, but on my template I get undefined variable

<h1>This will not</h1>
@cache('articles', 10)
    @foreach($articles as $article)
        {{ $article->name }}
    @endforeach
@endcache

Caching error pages

Hi,

I notices error pages (if a URL is not found) is cached and when the cache page is returned it's HTTP STATUS is 200 instead of the error code (404, 500 etc).

Undefined variables in Runtime Cache

Hi,

I'd like to base my app purely around the Runtime caching, since most of my users will be logged in and I don't want to cache all of (just about) any page.

I'm having some problems getting it running though - when I implemented it (without the blade shortcut style, just with the raw PHP call) I get an error about "undefined variables". In this example, it's $page that is undefined:

<?php Flatten::section('foo', 10, function() { ?>
    {{ $page->body }}
<?php }); ?>

This makes sense to me, given the way variable scoping works in PHP, and that I haven't specified use ($page) as part of the function definition. So I tried this:

<?php Flatten::section('foo', 10, function() use ($page) { ?>
    {{ $page->body }}
<?php }); ?>

But then when the cache is called, I just get an empty block back.

I'm having some trouble debugging this, so any thoughts or advice very welcome. In general - I love the API and I really, really hope I can get this working.

Thanks for putting the time into releasing this package.

Query string

Shouldn't the query string be added to salt/path? I know I can add it to the salt, but wouldn't it make sense to include it by default? Like for pagination, by default they all display the same page now..
(And Symfony Request normalizes the request string so you always have the same order, but then you'd also have to use that in Kickstart if you want)

Ignore cache on part of blade template

Heya!

I love this package and would really want to use it on my site, but I'm running into an issue with setting it up to ignore a certain section of my blade template. I have a master template that has all my users header information nav bar and what not that I want to have the cache ignore and only cache the content section of the page with the header always being dynamic.

I have a master.blade in layouts that injects a @yield('content") then sub templates that extend the master.blade with a @section('content') I only want to cache the @section piece of information. When trying the runtime I'm losing variable values.

Any help would be appreciated!

Enabled false not working

I have set 'enabled' => false, in both app\config\packages\anahkiasen\flatten\config.php and app\config\packages\anahkiasen\flatten\local\config.php but Flatten is still running. Changing the saltshaker shows the evn specific config file is being used as changing this makes a different cache file.

Release stable version

It appears having minimum-stability to stable causes issues with composer.

Loading composer repositories with package information
Updating dependencies (including require-dev)         
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - anahkiasen/flatten 0.4.2 requires philf/setting dev-master -> no matching package found.
    - anahkiasen/flatten 0.4.1 requires philf/setting dev-master -> no matching package found.
    - anahkiasen/flatten 0.4.0 requires philf/setting dev-master -> no matching package found.
    - Installation request for anahkiasen/flatten 0.4.* -> satisfiable by anahkiasen/flatten[0.4.0, 0.4.1, 0.4.2].

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Laravel has this as the default now so I imagine new projects trying to use this package may run into problems?

Homepage cache is wrong

For some reason the cache of the homepage does not display the homepage data, instead it show displays the data of another page. All other pages are cached properly. Any idea what might be causing this?

Kickstart pathing issue to Flatten.php

The documentation for using Kickstart, the pathing appears to be wrong:

require __DIR__.'/../vendor/anahkiasen/flatten/src/Flatten/Flatten.php';
require __DIR__.'/../vendor/anahkiasen/flatten/src/Flatten.php';

Redirect show a flash of HTML

I installed this into a larger project and noticed a problem. So I tested on a fresh install of Laravel 4 & this component I set my routes files like this.

<?php

Route::get('/', function()
{
    return Redirect::to('/redirect');
});

Route::get('/redirect', function()
{
    return View::make('hello');
});

The problem is that when my app returns a Redirect I get a flash of HTML.
See the below image.
screen shot 2013-09-30 at 10 26 04

This is usually caused by headers being sent before the Redirect header. Which means that Laravel has to send down this HTML page with a redirect meta tag to perform the redirect.

Also I could see that these redirect files were getting cached.

1440413155s:448:"<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta http-equiv="refresh" content="1;url=http://localhost:1337/redirect" />

        <title>Redirecting to http://localhost:1337/redirect</title>
    </head>
    <body>
        Redirecting to <a href="http://localhost:1337/redirect">http://localhost:1337/redirect</a>.
    </body>
</html>
<!-- cached on 2013-09-30 09:24:55 -->";

I don't think it is required to cache the response if it is a redirect.
In addition the location of the redirect could be from a POST or DB driven so could change and shouldn't be cache.

I'm submitting a PR so that redirect responses are not cached.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.