Giter VIP home page Giter VIP logo

page-cache's Introduction

Laravel Page Cache

Build Status Latest Stable Version Total Downloads License

This package allows you to easily cache responses as static files on disk for lightning fast page loads.


Introduction

While static site builders such as Jekyll and Jigsaw are extremely popular these days, dynamic PHP sites still offer a lot of value even for a site that is mostly static. A proper PHP site allows you to easily add dynamic functionality wherever needed, and also means that there's no build step involved in pushing updates to the site.

That said, for truly static pages on a site, there really is no reason to have to boot up a full PHP app just to serve a static page. Serving a simple HTML page from disk is infinitely faster and less taxing on the server.

The solution? Full page caching.

Using the middleware included in this package, you can selectively cache the response to disk for any given request. Subsequent calls to the same page will be served directly as a static HTML page!

Installation

Note: The current version of Page Cache requires PHP 8.2+ and Laravel 11+.

If you're on Laravel v5-v10, use Page Cache v1.0.9.

Install the page-cache package with composer:

$ composer require silber/page-cache

Middleware

Open app/Http/Kernel.php and add a new item to the web middleware group:

protected $middlewareGroups = [
    'web' => [
        \Silber\PageCache\Middleware\CacheResponse::class,
        /* ... keep the existing middleware here */
    ],
];

The middleware is smart enough to only cache responses with a 200 HTTP status code, and only for GET requests.

If you want to selectively cache only specific requests to your site, you should instead add a new mapping to the middlewareAliases array:

protected $middlewareAliases = [
    'page-cache' => \Silber\PageCache\Middleware\CacheResponse::class,
    /* ... keep the existing mappings here */
];

Once registered, you can then use this middleware on individual routes.

URL rewriting

In order to serve the static files directly once they've been cached, you need to properly configure your web server to check for those static files.

  • For nginx:

    Update your location block's try_files directive to include a check in the page-cache directory:

    location = / {
        try_files /page-cache/pc__index__pc.html /index.php?$query_string;
    }
    
    location / {
        try_files $uri $uri/ /page-cache/$uri.html /page-cache/$uri.json /page-cache/$uri.xml /index.php?$query_string;
    }
  • For apache:

    Open public/.htaccess and add the following before the block labeled Handle Front Controller:

    # Serve Cached Page If Available...
    RewriteCond %{REQUEST_URI} ^/?$
    RewriteCond %{DOCUMENT_ROOT}/page-cache/pc__index__pc.html -f
    RewriteRule .? page-cache/pc__index__pc.html [L]
    RewriteCond %{DOCUMENT_ROOT}/page-cache%{REQUEST_URI}.html -f
    RewriteRule . page-cache%{REQUEST_URI}.html [L]
    RewriteCond %{DOCUMENT_ROOT}/page-cache%{REQUEST_URI}.json -f
    RewriteRule . page-cache%{REQUEST_URI}.json [L]
    RewriteCond %{DOCUMENT_ROOT}/page-cache%{REQUEST_URI}.xml -f
    RewriteRule . page-cache%{REQUEST_URI}.xml [L]

Ignoring the cached files

To make sure you don't commit your locally-cached files to your git repository, add this line to your .gitignore file:

/public/page-cache

Usage

Using the middleware

Note: If you've added the middleware to the global web group, then all successful GET requests will automatically be cached. No need to put the middleware again directly on the route.

If you instead registered it in middlewareAliases, you should use the middleware on whichever routes you want to be cached.

To cache the response of a given request, use the page-cache middleware:

Route::middleware('page-cache')->get('posts/{slug}', 'PostController@show');

Every post will now be cached to a file under the public/page-cache directory, closely matching the URL structure of the request. All subsequent requests for this post will be served directly from disk, never even hitting your app!

Clearing the cache

Since the responses are cached to disk as static files, any updates to those pages in your app will not be reflected on your site. To update pages on your site, you should clear the cache with the following command:

php artisan page-cache:clear

As a rule of thumb, it's good practice to add this to your deployment script. That way, whenever you push an update to your site, the page cache will automatically be cleared.

If you're using Forge's Quick Deploy feature, you should add this line to the end of your Deploy Script. This'll ensure that the cache is cleared whenever you push an update to your site.

You may optionally pass a URL slug to the command, to only delete the cache for a specific page:

php artisan page-cache:clear {slug}

To clear everything under a given path, use the --recursive flag:

php artisan page-cache:clear {slug} --recursive

For example, imagine you have a category resource under /categories, with the following cached pages:

  • /categories/1
  • /categories/2
  • /categories/5

To clear the cache for all categories, use --recursive with the categories path:

php artisan page-cache:clear categories --recursive

Customizing what to cache

By default, all GET requests with a 200 HTTP response code are cached. If you want to change that, create your own middleware that extends the package's base middleware, and override the shouldCache method with your own logic.

  1. Run the make:middleware Artisan command to create your middleware file:

    php artisan make:middleware CacheResponse
    
  2. Replace the contents of the file at app/Http/Middleware/CacheResponse.php with this:

    <?php
    
    namespace App\Http\Middleware;
    
    use Symfony\Component\HttpFoundation\Request;
    use Symfony\Component\HttpFoundation\Response;
    use Silber\PageCache\Middleware\CacheResponse as BaseCacheResponse;
    
    class CacheResponse extends BaseCacheResponse
    {
        protected function shouldCache(Request $request, Response $response)
        {
            // In this example, we don't ever want to cache pages if the
            // URL contains a query string. So we first check for it,
            // then defer back up to the parent's default checks.
            if ($request->getQueryString()) {
                return false;
            }
    
            return parent::shouldCache($request, $response);
        }
    }
  3. Finally, update the middleware references in your app/Http/Kernel.php file, to point to your own middleware.

License

The Page Cache package is open-sourced software licensed under the MIT license.

page-cache's People

Contributors

andypa avatar atiksoftware avatar benabbottnz avatar hebbet avatar howdu avatar irineujunior avatar josephsilber avatar kodestar avatar laravel-shift avatar mvdnbrk avatar thijsvdanker 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

page-cache's Issues

getting cache path not set.

I am getting

Exception
Cache path not set.

    if (is_null($base)) {
        throw new Exception('Cache path not set.');
    }

what could be wrong here? I've tested it locally and it works just fine, but after I uploaded it to ftp it gives me that error.

Use .json file extension instead of .html for JSON responses

Hi Joseph,

I was wondering if you would accept a PR which adds the ability to store a response in a .json file instead of a .html, if the response itself is a JSON document. The reason behind it is that the content-type in the browser would automatically be correct.

Let me know what you think about it.

Cheers!

Compatibility with Laravel 5.5

Hi, can you please update composer.json to support laravel 5.5

"symfony/http-foundation": "^2.6.0|^3.0.0|^4.0.0"

Thanks

Partial slug cache clearing

Is it possible to use part of a slug to clear the cache?

My url looks like domain/section/id/item-name when something on the page is changed I'm running Artisan::call('page-cache:clear section/'.$id.'/'.$item->url); which works perfectly unless the thing that has changed is the $item->url then both item-name.hml and item-name-new.html exist and I can't 301 the old to the new because the old exists so gets returned.

If I could run Artisan::call('page-cache:clear section/'.$id); instead and clear everything in page-cache\section\id that would be a lot more flexible.

document suggestion for trailing slash

hi thr,
great package
this issue is for those who use trailing slash (like me) in thr url ! in that case default nginx configure doesnt work (i don't why)

here is nginx config

location = / {
	try_files /page-cache/pc__index__pc.html /index.php?$query_string;
}

location / {
	try_files $uri $uri/ /page-cache/$uri/pc__index__pc.html /index.php?$query_string;
}

Question....

if I have a names route ->route('test-page') which points to the following path: /test

The package will create a cache file test.html

Will the package return the cached file if I visit /test again in the browser or must the address now be /test.html?

Thanks!

Laravel 5.4 support

Hi! I getting error on laravel 5.4.

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for silber/page-cache dev-master -> satisfiable by silber/page-cache[dev-master].
    - Conclusion: remove laravel/framework v5.4.12
    - Conclusion: don't install laravel/framework v5.4.12
    - silber/page-cache dev-master requires illuminate/contracts 5.0.*|5.1.*|5.2.*|5.3.* -> satisfiable by illuminate/contracts[5.0.x-dev, 5.1.x-dev, 5.2.x-dev, 5.3.x-dev, v5.0.0, v5.0.33, v5.1.1, v5.1.13, v5.1.16, v5.1.20, v5.1.22, v5.1.25, v5.1.28, v5.1.30, v5.1.31, v5.1.41, v5.1.8, v5.2.0, v5.2.19, v5.2.21, v5.2.24, v5.2.25, v5.2.26, v5.2.27, v5.2.28, v5.2.31, v5.2.32, v5.2.37, v5.2.43, v5.2.45, v5.2.6, v5.2.7, v5.3.0, v5.3.16, v5.3.23, v5.3.4].
    - don't install illuminate/contracts 5.1.x-dev|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts 5.2.x-dev|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts 5.3.x-dev|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.1.1|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.1.13|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.1.16|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.1.20|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.1.22|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.1.25|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.1.28|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.1.30|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.1.31|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.1.41|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.1.8|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.2.0|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.2.19|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.2.21|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.2.24|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.2.25|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.2.26|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.2.27|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.2.28|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.2.31|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.2.32|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.2.37|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.2.43|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.2.45|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.2.6|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.2.7|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.3.0|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.3.16|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.3.23|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.3.4|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts 5.0.x-dev|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.0.0|don't install laravel/framework v5.4.12
    - don't install illuminate/contracts v5.0.33|don't install laravel/framework v5.4.12
    - Installation request for laravel/framework (locked at v5.4.12, required as 5.4.*) -> satisfiable by laravel/framework[v5.4.12].


Installation failed, reverting ./composer.json to its original content.

Doesn't work with / path and Apache

It doesn't seem to work with a root path (/) route and Apache.
The static html file is created with the file name ".html" (and recreated on every request), but I can see that PHP is responding instead of only Apache. The route "/en" is working as expected.

This is my route:

Route::get('/{locale?}', function ($locale = 'sv') {
    return view('start')->with('locale', $locale);
})->middleware(['page-cache']);

Otherwise, great package :)

how it detect change

hi . this good package , i have a question ! .

do after update page in admin , in front get last update and cache it for next time ?

but i change cache page in public and not load in cache !

Not created cached files

Hello.

I'm trying use page-cache and i readed the read.md and i did the step by step, but the laravel do not create cached files...

No errors show and the file is not created.
My responsecache.php is default.
My Laravel is 5.5.40

Caching page from file does not open

Good afternoon.

Laravel 7 / Mamp PRO / Apache

I did everything according to the instructions, cache files are created successfully.
But upon repeated access, the page cache file is not opened, but simply a new file is recreated.

Please tell me what can I do wrong?

I assume that the case is in htaccess file. Here are its contents:
`

Options -MultiViews -Indexes

RewriteEngine On

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

# Serve Cached Page If Available...
RewriteCond %{REQUEST_URI} ^/?$
RewriteCond %{DOCUMENT_ROOT}/page-cache/pc__index__pc.html -f
RewriteRule .? page-cache/pc__index__pc.html [L]
RewriteCond %{DOCUMENT_ROOT}/page-cache%{REQUEST_URI}.html -f
RewriteRule . page-cache%{REQUEST_URI}.html [L]

# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

# редирект на без www
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule .* http://%1/$0 [L,R=301]

# редирект с index.php на корень
RewriteCond %{THE_REQUEST} ^.*/index\.php 
RewriteRule ^(.*)index.php$ /$1 [R=301,L] 

`

csrf

how about pages contains csrf token ?

How to handle urls that sometimes contain a querystring

Its unclear to me how to handle urls that may sometimes contain a query string.

For example, if you have a /blog url, and then pagination (/blog?page=2, /blog?page=3), etc.

Unless I'm missing something, this package cannot handle query string's at all - it looks like only the actual uri is cached, and not the query string. Hence the example on the front page of the package demonstrating how to exclude routes that contain a query string.

However, even if you implement that method, then the main /blog page will still get cached, which means that nginx will automatically serve up that same page for anything with a query string.

I think there are 2 options here:

  • Don't implement caching at all for the /blog route
  • Somehow include query strings in the page-cache files (is this even possible)?

Subdomain cache

Hi,

I using subdomain route. But all subdomain same request uri. Your plugin confusing address.

My route;
Route::group(['domain' => '{language}.site.test','middleware' => 'page-cache'], function () { Route::group(['as' => 'front.subdomain.', 'namespace' => 'Front'], function ($language) { $this->paginate('/', ['as' => 'home', 'uses' => 'SubDomainController@index']); // Route::paginate('/', 'SubDomainController@index'); $this->get('/{slug}', ['as' => 'post', 'uses' => 'SubDomainController@post']); }); });

Tests without assertions

The following tests don't have any assertions:

  • Silber\PageCache\Tests\CacheTest::testCachesRootToSpecialFilename
  • Silber\PageCache\Tests\CacheTest::testCachesJsonResponsesWithJsonExtension

Cached pages csrf_token problem

Hi!

First of all what a great package, I have never seen any site load this fast! (Of course serving static html sites is incredibily fast). The only issue I am facing is, that since this package caches a static html version of the corresponding page, the csrf toke in the head is also going to be static. Resulting in broken AJAX calls...

Is there anyway to fix this?

Clear a specific cached file on edit, delete or create

Is it possible to target a particular cached file so in order to view on the front end an edit, created or deleted the item?

For instance, say I had a news site. When I create a new article, edit or even delete a new article, I would expect to see the change on the listings page, or on the article page etc. But because the sites cached it does not show.

So I would then clear all in order to view the one updated article?

So is there a way to call a function etc on say the update method, that would simply just clear the given article, and the listings page, so when I then visit those pages I see the changes immediately.

I don't just want to run the clear cache each time and having the other pages re-cached? Also, a user might not be able to use the terminal online, as they are just an editor?

Hope this makes sense.

Suggestions: no-page-cache route middleware and PAGE_CACHE_ENABLED env variable

Thanks for this package. Three suggestions:

  1. Add a PAGE_CACHE_ENABLED environment variable with supporting config file that checks for this. This allows the cache to be turned on and off instead of having to comment out the reference in Kernel.php

  2. You have a page-cache route middleware, but how about doing the inverse: a no-page-cache middleware? This'll allow an individual route(s) to be excluded easily while caching everything else by default.

  3. Regex cache clearing. Right now, an individual slug can be cleared:

php artisan page-cache:clear {slug}

But what about extending it to clear a directory, like so:

php artisan page-cache:clear country/canada/*

Or just clearing anything that matches:

php artisan page-cache:clear country/canad*

If full-blown regex is too much work to do, at least supporting the asterisk seems to be a reasonable middle ground.

Thanks.

Exclude pages with query string

Hi,

If I follow the example on the readme, and I exclude pages with query string (e.g. /services?utm=XXXXX)

Does it also exclude the underlying page (e.g. /services)?

We generate dynamic content on our pages based on the Ad Keyword, and would like to exclude these pages from caching.

Thanks,

Cache path not set.

Im getting

Cache path not set.

in Cache.php line 81

error in my local server. I've used routing middleware for my code.

Route::middleware('page-cache')->get('reportcard', ['uses' => 'StatisticsController@reportCard2', 'as' => 'school.statistics2']);

Proposal: Adding the possibility of use in projects with different domains.

Hello,
By changing one line, functionality can be added to use the plugin with different domains.

In the file src/Cache.php on line 198:

- $segments = explode('/', ltrim($request->getPathInfo(), '/'));
+ $segments = explode('/', ltrim($request->getHost() . $request->getPathInfo(), '/'));

It has been tested on Laravel 7 and it works for me. Is it a good idea? Is there something I'm missing?

How to set cache header?

I am using this package and its working as mentioned. But is there a way to determine if page is served by cache or from server?
I mean, can we set a header something like x-page-cache: HIT if page is served via cache and x-page-cache-:MISS if page is delivered from server ?

Support for QueryString

I made an implementation, but I can not do the merge, because I do not know how to test in Apache, and I do not have the time.

is my suggestion for this functionality.

Replace in method: getDirectoryAndFileNames()

$segments = explode('/', ltrim($request->getPathInfo().$request->getQueryString(), '/'));

and use in nginx

try_files $uri $uri/ /page-cache/$uri$query_string.html/index.php?$query_string;

csrf-token on cached files

Now since the enture page is cached as HTML. The csrf tokens in web forms would also be cached.

I was wondering, what would be the best way to keep the csrf tokens fresh for each user who visits a cached page?

index.php shown in url for cached pages

First of all, thanks for this great package.

index.php shown in url

I have tested it on our simple Laravel website and found a little quirk.
When visiting a cached page, the displayed url includes index.php
This is not beneficial for SEO and UX, therefore I would like to change it.

Have anyone else experienced this issue and found a work around?

Prior to installing this package, urls where in the form of https://app_url.com/route

After installation and visiting all package to warm the cache, the urls are now in the form of https://app_url.com/index.php/route

Outcommenting the recommended lines from .htaccess resolves the problem, but views are no longer served from cache.

Apache configuration

Apache running with PHP 7.2
The full .htaccess file is as follows

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Serve Cached Page If Available...
    RewriteCond %{REQUEST_URI} ^/?$
    RewriteCond %{DOCUMENT_ROOT}/page-cache/pc__index__pc.html -f
    RewriteRule .? page-cache/pc__index__pc.html [L]
    RewriteCond %{DOCUMENT_ROOT}/page-cache%{REQUEST_URI}.html -f
    RewriteRule . page-cache%{REQUEST_URI}.html [L]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

# BEGIN Expires-Headers
<IfModule mod_expires.c>
  <FilesMatch "\.(js|css)$">
    ExpiresActive On
    ExpiresDefault "access plus 4 weeks"
  </FilesMatch>
</IfModule>
# END Expires-Headers

# BEGIN Cache-Control-Headers
<ifmodule mod_headers.c>
  <filesmatch "(gif|ico|jpeg|jpe|jpg|svg|png|css|js)$">
    Header set Cache-Control "max-age=604800, public"
  </filesmatch>
</ifmodule>
# END Cache-Control-Headers

Device specific cache

I have a few links especially the social media links whose links are created as per the device.
How can I generate a device specific cache.

Does not work try_files for main page in nginx

Hello. I use nginx and laravel 5.4. Html file pc__index__pc.html is created in page-cache folder, but nginx does not see it.

My nginx config:

     location / {
		try_files $uri $uri/ /page-cache/$uri.html /index.php?$query_string;
	}
	
	location ~ \..*/.*\.php$ {
		# For super-cool-hackers
		return 403;
	}
	
	location ~ \.php$ {
		try_files $uri /index.php =404;
		fastcgi_pass 127.0.0.1:9000;
		fastcgi_split_path_info ^(.+\.php)(/.*)$;
		fastcgi_index index.php;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		include fastcgi_params;
		fastcgi_read_timeout 300;
	}

Tell me please, what is wrong?

Purge cache via command?

Let’s say I want to purge a route or everything because of some business logic.
Could we create an artisan command for this feature?

Common usecase would be a website update from the backend, and an observer needs to Purge some cached routes.

Page not loading from cached file

I am using this plugin,
page cache is properly created in page cache folder but its not loading from it,

my htaccess as below (puted in htaccess in root not in public)

RewriteCond %{REQUEST_URI} ^/?$
RewriteCond %{DOCUMENT_ROOT}/public/page-cache/pc__index__pc.html -f
RewriteRule .? public/page-cache/pc__index__pc.html [L]
RewriteCond %{DOCUMENT_ROOT}public/page-cache%{REQUEST_URI}.html -f
RewriteRule . public/page-cache%{REQUEST_URI}.html [L]

Cache tags

Is there a way to use this package with cache tags so one can flush only parts of the cached requests?

Routes with the same url for post and get

doesn't seem to work with POST and GET pages with the same url. looks like it redirects back to the GET page. example like when i have urls GET site.com/post and POST site.com/post, when i submit the form it just redirects back to the post page.

Doesn't show cached files with 'artisan serve'

To see cached files using the PHP built-in web server you need to add this to the bottom of server.php:

if (file_exists(__DIR__.'/public/page-cache/pc__index__pc.html'))
    require_once __DIR__.'/public/page-cache/pc__index__pc.html';
else
    require_once __DIR__.'/public/index.php';

Document suggestion for cache invalidation

Since the PHP stack is out of reach, I don't see how cache invalidation works.
For example, to renew the generated start page of a content driven site every 10 minutes.
Please provide a suggestion how to handle that.

Thanks in advance.

NGINX duplicate location "/"

In forge when trying to add

location = / {
    try_files /page-cache/pc__index__pc.html /index.php?$query_string;
}

location / {
    try_files $uri $uri/ /page-cache/$uri.html /index.php?$query_string;
}

I get an nginx error "duplicate location /

Is this a new problem with NGINX?
Is there a way to account for the home page and all other pages?
Thanks in advance.

Fix Laravel 7 support because of symfony dependency

Hi, I think you forgot to update the symfony/http-foundation dependency when you updated to support Laravel 7. It needs ^5.0 but this package says: "symfony/http-foundation": "2.6 - 4" and because of that I cannot update an app to Laravel 7 which requires this package.

Dynamic data

Hi,

I am wondering if I have a page that shows all the articles, how will the package know when to clear the cache? Do I have to clear the cache when there is a new article added to the DB?

Thanks,

Logged in users

Hi!
Is there any way of caching pages only if there is no user logged in? Or cache it for each user who is logged in?
Reason being that there might be a custom header with the username....

Any advice on how to solve that?

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.