I'm building a custom module like described here (https://www.drupal.org/docs/creating-custom-modules) for drupal 8. That's mostly dynamic content that changes with some WebServices calls. My problem is that the internal drupal 8 cache is automatically caching everything, including token and javascripts.
So question is :
- can I define somewhere in the module, don't cache it?
Thanks
Not sure if you're dealing with render array caching, but if so you could try:
$build['#cache']['max-age'] = 0;
You can read more about it in Cacheability of render arrays.
Related
I want to create a quick page load response in ASP.NET MVC .
If I use [outputCache] then it saves the whole page with the dynamic parts and then a new client will see previous client information.
What is the Best Practice to Do It?
I saw that there is a Cache Tag Helper but will it be faster?
Because I still have to go into the Action and and rendering the page except for the section of the Cache Tag Helper.
Many thanks to those who have an optimal and fast solution.
In the docs for response caching, Microsoft has a prominent warning:
Disable caching for content that contains information for
authenticated clients. Caching should only be enabled for content that
doesn't change based on a user's identity or whether a user is signed
in.
As you indicate, your scenario involves dynamic authenticated content. Thus you should avoid caching the rendered output as a whole, and maybe consider caching specific data or elements within a page only if you're very careful and performance requires it. Otherwise, safer to leave defaults. ASP.NET Core is very fast -- it's unlikely the rendering is the bottleneck in most cases.
So I'm building a website with Drupal as its backend and an Angular frontend. I'm creating all kinds of content-types in Drupal and then I'm exposing those the content through a JSON view (or in other words a RESTful API). However, Drupal also still exposes an HTML view for all content. I wish to disable that, because it is of no use to me and I don't want it to be accidentally found and maybe even indexed.
Is there an easy way to disable the HTML view for all content?
hook_entity_view and from there block access or change render could be one solution
Have your webserver deny based on the content type sent. I believe nginx has $sent_http_content_type for this purpose.
Alternatively, write an event subscriber subscribing to KernelEvents::RESPONSE and if the response is not a ResourceResponseInterface then throw an AccessDeniedHttpException.
I have a collection of 15k+ objects(database) that I want to send to the client(an application). This can take up to 30sec to sync.
I would like a way to keep cache between user visits so I only need to sync the difference since my last visit.
It would be also nice to be able to share that local cache between browser tabs.
In theory I don't see why it would be hard to do so, but I am uncertain how to do it.
*As pointed out by #zeroasterisk it is a database cache I am looking for, not simply static files.
Have you looked at the smart package "appcache" ?
code: https://github.com/awwx/meteor-appcache
info: http://docs.meteor.com/#appcache
more: https://github.com/meteor/meteor/wiki/AppCache
The appcache package stores the static parts of a Meteor application (the client side Javascript, HTML, CSS, and images) in the browser's application cache. To enable caching simply add the appcache package to your project.
It doesn't currently support data in collections, which is what I think you were asking about, but it might be something you could extend. If I mis-understood the question and you just need to store static objects (JS files, etc) this will work great.
more on this here: Can Meteor's Appcache also store database data?
note: it is disabled by default in FF because of user prompts...
Whenever i enable content access module in drupal it slows down the site a lot , disabling it makes the site load properly. Are there any other modules which could be instead of content access?
Aditya
If you are asking what other access modules you can use, you might try Nodeaccess
There are many more as well, see a list of possible modules at http://drupal.org/node/270000
Other content access modules might just was result in the same slowdown. All these modules just add access rules to Drupal, the part that actuall looks for the permission is in Drupal core.
Instead, what I would try to do is install devel.module and print the executed sql queries. Then, look queries are actually slow and try to optimize them by adding indexes.
Maybe this only happens in combination with another module because it executes crappy queries.
I need to enable caching in my asp.net application, but I do not want to use the webserver's memory for holding cache objects. If I add the page directive for output caching will the page be stored in the asp.net cache object?
Thanks!
The default behaviour is to store the content in memory in the same way as HttpRuntime.Cache (actually in an internal HttpRuntime.CacheInternal which behaves similarly to the publicly visible cache), but in ASP.NET 4.0 you can write your own provider to store the content however you wish.
This a nice introduction to implementing a provider and using it in your application: http://dotnet.dzone.com/news/aspnet-output-cache-provider
It depends what you set as OutputCacheLocation
have a look at:
http://msdn.microsoft.com/en-us/library/system.web.ui.outputcachelocation.aspx